[Pkg-bazaar-commits] ./bzr/unstable r555: - New Inventory.entries() method

Martin Pool mbp at sourcefrog.net
Fri Apr 10 08:19:21 UTC 2009


------------------------------------------------------------
revno: 555
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Wed 2005-05-25 13:48:09 +1000
message:
  - New Inventory.entries() method
modified:
  bzrlib/inventory.py
-------------- next part --------------
=== modified file 'bzrlib/inventory.py'
--- a/bzrlib/inventory.py	2005-05-19 11:07:36 +0000
+++ b/bzrlib/inventory.py	2005-05-25 03:48:09 +0000
@@ -329,7 +329,25 @@
             if ie.kind == 'directory':
                 for cn, cie in self.iter_entries(from_dir=ie.file_id):
                     yield os.path.join(name, cn), cie
-                    
+
+
+    def entries(self):
+        """Return list of (path, ie) for all entries except the root.
+
+        This may be faster than iter_entries.
+        """
+        def accum(self, dir_ie, dir_path, a):
+            kids = from_dir.children.items()
+            kids.sort()
+            for name, ie in kids:
+                child_path = os.path.join(dir_path, name)
+                a.append((child_path, ie))
+                if ie.kind == 'directory':
+                    accum(ie, ie, child_path, a)
+
+        a = []
+        accumt(self, self.root, a)
+        return a
 
 
     def directories(self):



More information about the Pkg-bazaar-commits mailing list