Rev 5843: (jelmer) Deprecate Tree.__iter__. (Jelmer Vernooij) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Mon May 9 14:47:15 UTC 2011
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5843 [merge]
revision-id: pqm at pqm.ubuntu.com-20110509144711-b87xrawe7hozixek
parent: pqm at pqm.ubuntu.com-20110509105953-n94q63064kk8s0ui
parent: jelmer at samba.org-20110509135520-8r5rgkjd30iunztg
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2011-05-09 14:47:11 +0000
message:
(jelmer) Deprecate Tree.__iter__. (Jelmer Vernooij)
modified:
bzrlib/bundle/bundle_data.py read_changeset.py-20050619171944-c0d95aa685537640
bzrlib/tests/per_interrepository/test_fetch.py test_fetch.py-20080425213627-j60cjh782ufm83ry-1
bzrlib/tests/per_tree/test_test_trees.py test_tree_trees.py-20060720091921-3nwi5h21lf06vf5p-1
bzrlib/tests/per_workingtree/test_add.py test_add.py-20070226165239-4vo178spkrnhavc7-1
bzrlib/tests/per_workingtree/test_readonly.py test_readonly.py-20061219164256-7imbl63m4j15n0es-1
bzrlib/tests/test_bundle.py test.py-20050630184834-092aa401ab9f039c
bzrlib/tests/test_revisiontree.py test_revisiontree.py-20060615095324-aij44ndxbv1h4c9f-1
bzrlib/tree.py tree.py-20050309040759-9d5f2496be663e77
bzrlib/workingtree.py workingtree.py-20050511021032-29b6ec0a681e02e3
doc/en/release-notes/bzr-2.4.txt bzr2.4.txt-20110114053217-k7ym9jfz243fddjm-1
=== modified file 'bzrlib/bundle/bundle_data.py'
--- a/bzrlib/bundle/bundle_data.py 2011-04-19 14:12:43 +0000
+++ b/bzrlib/bundle/bundle_data.py 2011-05-08 13:07:11 +0000
@@ -763,7 +763,7 @@
paths = []
for result in self._new_id.iteritems():
paths.append(result)
- for id in self.base_tree:
+ for id in self.base_tree.all_file_ids():
path = self.id2path(id)
if path is None:
continue
=== modified file 'bzrlib/tests/per_interrepository/test_fetch.py'
--- a/bzrlib/tests/per_interrepository/test_fetch.py 2011-03-28 04:24:47 +0000
+++ b/bzrlib/tests/per_interrepository/test_fetch.py 2011-05-08 13:07:11 +0000
@@ -76,7 +76,7 @@
tree.lock_read()
self.addCleanup(tree.unlock)
tree.get_file_text('file1')
- for file_id in tree:
+ for file_id in tree.all_file_ids():
if tree.inventory[file_id].kind == "file":
tree.get_file(file_id).read()
=== modified file 'bzrlib/tests/per_tree/test_test_trees.py'
--- a/bzrlib/tests/per_tree/test_test_trees.py 2009-07-10 07:14:02 +0000
+++ b/bzrlib/tests/per_tree/test_test_trees.py 2011-05-08 13:07:11 +0000
@@ -30,7 +30,7 @@
self.assertEqual([], tree.get_parent_ids())
self.assertEqual([], tree.conflicts())
self.assertEqual([], list(tree.unknowns()))
- self.assertEqual(['empty-root-id'], list(iter(tree)))
+ self.assertEqual(['empty-root-id'], list(tree.all_file_ids()))
self.assertEqual(
[('', 'empty-root-id')],
[(path, node.file_id) for path, node in tree.iter_entries_by_dir()])
@@ -46,7 +46,7 @@
# __iter__ has no strongly defined order
self.assertEqual(
set(['root-id', 'a-id', 'b-id', 'c-id']),
- set(iter(tree)))
+ set(tree.all_file_ids()))
self.assertEqual(
[('', 'root-id'), ('a', 'a-id'), ('b', 'b-id'), ('b/c', 'c-id')],
[(path, node.file_id) for path, node in tree.iter_entries_by_dir()])
@@ -64,7 +64,7 @@
# __iter__ has no strongly defined order
self.assertEqual(
set(['root-id', 'a-id', 'b-id', 'c-id']),
- set(iter(tree)))
+ set(tree.all_file_ids()))
self.assertEqual(
[('', 'root-id'), ('a', 'a-id'), ('b', 'b-id'), ('b/c', 'c-id')],
[(path, node.file_id) for path, node in tree.iter_entries_by_dir()])
@@ -82,7 +82,7 @@
# __iter__ has no strongly defined order
self.assertEqual(
set(['root-id', 'a-id', 'b-id', 'c-id']),
- set(iter(tree)))
+ set(tree.all_file_ids()))
self.assertEqual(
[('', 'root-id'), ('a', 'a-id'), ('b', 'b-id'), ('b/c', 'c-id')],
[(path, node.file_id) for path, node in tree.iter_entries_by_dir()])
@@ -100,7 +100,7 @@
# __iter__ has no strongly defined order
self.assertEqual(
set(['root-id', 'a-id', 'b-id', 'c-id']),
- set(iter(tree)))
+ set(tree.all_file_ids()))
self.assertEqual(
[('', 'root-id'), ('b', 'b-id'), ('d', 'a-id'), ('b/c', 'c-id')],
[(path, node.file_id) for path, node in tree.iter_entries_by_dir()])
@@ -118,7 +118,7 @@
# __iter__ has no strongly defined order
self.assertEqual(
set(['root-id', 'a-id', 'b-id', 'c-id']),
- set(iter(tree)))
+ set(tree.all_file_ids()))
self.assertEqual(
[('', 'root-id'), ('b', 'b-id'), ('d', 'a-id'), ('b/c', 'c-id')],
[(path, node.file_id) for path, node in tree.iter_entries_by_dir()])
@@ -136,7 +136,7 @@
# __iter__ has no strongly defined order
self.assertEqual(
set(['root-id', 'a-id', 'b-id', 'c-id']),
- set(iter(tree)))
+ set(tree.all_file_ids()))
self.assertEqual(
[('', 'root-id'), ('a', 'a-id'), ('b', 'b-id'), ('e', 'c-id')],
[(path, node.file_id) for path, node in tree.iter_entries_by_dir()])
@@ -165,7 +165,7 @@
u'0utf\u1234file'.encode('utf8'),
'symlink',
]),
- set(iter(tree)))
+ set(tree.all_file_ids()))
# note that the order of the paths and fileids is deliberately
# mismatched to ensure that the result order is path based.
self.assertEqual(
@@ -198,7 +198,7 @@
'0dir-in-1topdir',
u'0utf\u1234file'.encode('utf8'),
]),
- set(iter(tree)))
+ set(tree.all_file_ids()))
# note that the order of the paths and fileids is deliberately
# mismatched to ensure that the result order is path based.
self.assertEqual(
=== modified file 'bzrlib/tests/per_workingtree/test_add.py'
--- a/bzrlib/tests/per_workingtree/test_add.py 2011-05-04 21:10:36 +0000
+++ b/bzrlib/tests/per_workingtree/test_add.py 2011-05-08 13:07:11 +0000
@@ -150,7 +150,7 @@
tree = self.make_branch_and_tree('.')
tree.lock_write()
tree.add('')
- self.assertEqual([tree.path2id('')], list(tree))
+ self.assertEqual([tree.path2id('')], list(tree.all_file_ids()))
# the root should have been changed to be a new unique root.
self.assertNotEqual(inventory.ROOT_ID, tree.path2id(''))
tree.unlock()
=== modified file 'bzrlib/tests/per_workingtree/test_readonly.py'
--- a/bzrlib/tests/per_workingtree/test_readonly.py 2011-05-04 11:15:37 +0000
+++ b/bzrlib/tests/per_workingtree/test_readonly.py 2011-05-08 13:07:11 +0000
@@ -105,7 +105,7 @@
if hack_dirstate:
tree._dirstate._sha_cutoff_time = self._custom_cutoff_time
# Make sure we check all the files
- for file_id in tree:
+ for file_id in tree.all_file_ids():
size = tree.get_file_size(file_id)
sha1 = tree.get_file_sha1(file_id)
finally:
=== modified file 'bzrlib/tests/test_bundle.py'
--- a/bzrlib/tests/test_bundle.py 2011-04-19 14:19:50 +0000
+++ b/bzrlib/tests/test_bundle.py 2011-05-09 13:55:20 +0000
@@ -65,6 +65,7 @@
class MockTree(object):
+
def __init__(self):
from bzrlib.inventory import InventoryDirectory, ROOT_ID
object.__init__(self)
@@ -75,8 +76,8 @@
inventory = property(lambda x:x)
- def __iter__(self):
- return self.paths.iterkeys()
+ def all_file_ids(self):
+ return set(self.paths.keys())
def __getitem__(self, file_id):
if file_id == self.root.file_id:
@@ -493,7 +494,7 @@
% (ancestor,))
# Now check that the file contents are all correct
- for inventory_id in old:
+ for inventory_id in old.all_file_ids():
try:
old_file = old.get_file(inventory_id)
except errors.NoSuchFile:
=== modified file 'bzrlib/tests/test_revisiontree.py'
--- a/bzrlib/tests/test_revisiontree.py 2011-04-17 23:35:01 +0000
+++ b/bzrlib/tests/test_revisiontree.py 2011-05-09 13:55:20 +0000
@@ -75,7 +75,7 @@
tree.get_file_revision(tree.path2id('a')))
def test_get_file_mtime_ghost(self):
- file_id = iter(self.rev_tree).next()
+ file_id = iter(self.rev_tree.all_file_ids()).next()
self.rev_tree.inventory[file_id].revision = 'ghostrev'
self.assertRaises(errors.FileTimestampUnavailable,
self.rev_tree.get_file_mtime, file_id)
=== modified file 'bzrlib/tree.py'
--- a/bzrlib/tree.py 2011-05-08 12:54:20 +0000
+++ b/bzrlib/tree.py 2011-05-09 10:20:17 +0000
@@ -39,6 +39,10 @@
from bzrlib.decorators import needs_read_lock
from bzrlib.inter import InterObject
+from bzrlib.symbol_versioning import (
+ deprecated_in,
+ deprecated_method,
+ )
class Tree(object):
@@ -137,13 +141,9 @@
"""
return False
- def __iter__(self):
- """Yield all file ids in this tree."""
- raise NotImplementedError(self.__iter__)
-
def all_file_ids(self):
"""Iterate through all file ids, including ids for missing files."""
- return set(self.inventory)
+ raise NotImplementedError(self.all_file_ids)
def id2path(self, file_id):
"""Return the path for a file id.
@@ -757,6 +757,10 @@
def has_or_had_id(self, file_id):
return self.inventory.has_id(file_id)
+ def all_file_ids(self):
+ return set(self.inventory)
+
+ @deprecated_method(deprecated_in((2, 4, 0)))
def __iter__(self):
return iter(self.inventory)
=== modified file 'bzrlib/workingtree.py'
--- a/bzrlib/workingtree.py 2011-05-08 13:50:25 +0000
+++ b/bzrlib/workingtree.py 2011-05-09 11:59:04 +0000
@@ -2088,9 +2088,7 @@
__contains__ = has_id
- # should be deprecated - this is slow and in any case treating them as a
- # container is (we now know) bad style -- mbp 20070302
- ## @deprecated_method(zero_fifteen)
+ @symbol_versioning.deprecated_method(symbol_versioning.deprecated_in((2, 4, 0)))
def __iter__(self):
"""Iterate through file_ids for this tree.
=== modified file 'doc/en/release-notes/bzr-2.4.txt'
--- a/doc/en/release-notes/bzr-2.4.txt 2011-05-09 10:05:41 +0000
+++ b/doc/en/release-notes/bzr-2.4.txt 2011-05-09 11:59:04 +0000
@@ -76,6 +76,9 @@
``Branch._last_revision_info`` has been renamed to
``Branch._read_last_revision_info`` (Jelmer Vernooij)
+* ``Tree.__iter__`` has been deprecated; use ``Tree.all_file_ids``
+ instead. (Jelmer Vernooij)
+
Internals
*********
More information about the bazaar-commits
mailing list