Rev 5281: (mbp) 'bzr init' does not scan existing directory content anymore. (#501307) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Fri Jun 4 09:54:52 BST 2010


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 5281 [merge]
revision-id: pqm at pqm.ubuntu.com-20100604085449-n7lw5cj01w94ygxu
parent: pqm at pqm.ubuntu.com-20100604055955-98pfcy1bn8oz7749
parent: parth.malwankar at gmail.com-20100529154014-faqc89yv2jl41q1j
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2010-06-04 09:54:49 +0100
message:
  (mbp) 'bzr init' does not scan existing directory content anymore. (#501307)
   (Parth Malwankar)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/transform.py            transform.py-20060105172343-dd99e54394d91687
=== modified file 'NEWS'
--- a/NEWS	2010-06-04 03:09:35 +0000
+++ b/NEWS	2010-06-04 08:54:49 +0000
@@ -20,6 +20,10 @@
 Bug Fixes
 *********
 
+* ``bzr init`` does not recursively scan directory contents anymore
+  leading to faster init for directories with existing content.
+  (Martin [gz], Parth Malwankar, #501307)
+
 * Final fix for 'no help for command' issue. We now show a clean message
   when a command has no help, document how to set help more clearly, and
   test that all commands available to the test suite have help.

=== modified file 'bzrlib/transform.py'
--- a/bzrlib/transform.py	2010-05-25 17:27:52 +0000
+++ b/bzrlib/transform.py	2010-05-29 15:40:14 +0000
@@ -2291,9 +2291,6 @@
     for num, _unused in enumerate(wt.all_file_ids()):
         if num > 0:  # more than just a root
             raise errors.WorkingTreeAlreadyPopulated(base=wt.basedir)
-    existing_files = set()
-    for dir, files in wt.walkdirs():
-        existing_files.update(f[0] for f in files)
     file_trans_id = {}
     top_pb = bzrlib.ui.ui_factory.nested_progress_bar()
     pp = ProgressPhase("Build phase", 2, top_pb)
@@ -2323,6 +2320,15 @@
                 precomputed_delta = []
             else:
                 precomputed_delta = None
+            # Check if tree inventory has content. If so, we populate
+            # existing_files with the directory content. If there are no
+            # entries we skip populating existing_files as its not used.
+            # This improves performance and unncessary work on large
+            # directory trees. (#501307)
+            if total > 0:
+                existing_files = set()
+                for dir, files in wt.walkdirs():
+                    existing_files.update(f[0] for f in files)
             for num, (tree_path, entry) in \
                 enumerate(tree.inventory.iter_entries_by_dir()):
                 pb.update("Building tree", num - len(deferred_contents), total)




More information about the bazaar-commits mailing list