Rev 6474: (jelmer) Use Tree.iter_children() in a couple more places. (Jelmer Vernooij) in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/

Patch Queue Manager pqm at pqm.ubuntu.com
Thu Feb 23 19:39:08 UTC 2012


At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 6474 [merge]
revision-id: pqm at pqm.ubuntu.com-20120223193907-11erj8xxjmrchawp
parent: pqm at pqm.ubuntu.com-20120223191101-x6g60ci59rhkvp3e
parent: jelmer at samba.org-20120223184826-9fsmk02x92ms9kmf
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2012-02-23 19:39:07 +0000
message:
  (jelmer) Use Tree.iter_children() in a couple more places. (Jelmer Vernooij)
modified:
  bzrlib/merge.py                merge.py-20050513021216-953b65a438527106
  bzrlib/tree.py                 tree.py-20050309040759-9d5f2496be663e77
=== modified file 'bzrlib/merge.py'
--- a/bzrlib/merge.py	2012-02-17 16:40:16 +0000
+++ b/bzrlib/merge.py	2012-02-23 19:39:07 +0000
@@ -1102,11 +1102,12 @@
             # other_root doesn't have a physical representation. We still need
             # to move any references to the actual root of the tree.
             other_root_is_present = False
-        # 'other_tree.inventory.root' is not present in this tree. We are
+        # the other tree root is not present in this tree. We are
         # calling adjust_path for children which *want* to be present with a
         # correct place to go.
-        for _, child in self.other_tree.inventory.root.children.iteritems():
-            trans_id = self.tt.trans_id_file_id(child.file_id)
+        for child_id in self.other_tree.iter_children(
+                self.other_tree.get_root_id()):
+            trans_id = self.tt.trans_id_file_id(child_id)
             if not other_root_is_present:
                 if self.tt.final_kind(trans_id) is not None:
                     # The item exist in the final tree and has a defined place

=== modified file 'bzrlib/tree.py'
--- a/bzrlib/tree.py	2012-01-24 17:18:38 +0000
+++ b/bzrlib/tree.py	2012-02-23 18:48:26 +0000
@@ -532,13 +532,16 @@
         return find_ids_across_trees(paths, [self] + list(trees), require_versioned)
 
     def iter_children(self, file_id):
-        entry = self.iter_entries_by_dir([file_id]).next()[1]
-        for child in getattr(entry, 'children', {}).itervalues():
-            yield child.file_id
+        """Iterate over the file ids of the children of an entry.
+
+        :param file_id: File id of the entry
+        :return: Iterator over child file ids.
+        """
+        raise NotImplementedError(self.iter_children)
 
     def lock_read(self):
         """Lock this tree for multiple read only operations.
-        
+
         :return: A bzrlib.lock.LogicalLockResult.
         """
         pass
@@ -872,6 +875,12 @@
     def get_file_by_path(self, path):
         return self.get_file(self.path2id(path), path)
 
+    def iter_children(self, file_id, path=None):
+        """See Tree.iter_children."""
+        entry = self.iter_entries_by_dir([file_id]).next()[1]
+        for child in getattr(entry, 'children', {}).itervalues():
+            yield child.file_id
+
 
 def find_ids_across_trees(filenames, trees, require_versioned=True):
     """Find the ids corresponding to specified filenames.
@@ -1335,8 +1344,8 @@
                         if old_entry is None:
                             # Reusing a discarded change.
                             old_entry = self._get_entry(self.source, file_id)
-                        for child in old_entry.children.values():
-                            precise_file_ids.add(child.file_id)
+                        for child in self.source.iter_children(file_id):
+                            precise_file_ids.add(child)
                     changed_file_ids.add(result[0])
                     yield result
 




More information about the bazaar-commits mailing list