/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

  • Committer: Parth Malwankar
  • Date: 2010-05-29 04:04:22 UTC
  • mto: This revision was merged to the branch mainline in revision 5281.
  • Revision ID: parth.malwankar@gmail.com-20100529040422-f6b43yxabadx2i5b
keep the tree_entries list lazy to ensure progress bar works
correctly. closes review comment by Martin[gz].

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
from bzrlib.lazy_import import lazy_import
23
23
lazy_import(globals(), """
 
24
import itertools
 
25
 
24
26
from bzrlib import (
25
27
    annotate,
26
28
    bencode,
2320
2322
                precomputed_delta = []
2321
2323
            else:
2322
2324
                precomputed_delta = None
2323
 
            tree_entries = list(enumerate(tree.inventory.iter_entries_by_dir()))
2324
 
            if tree_entries:
 
2325
 
 
2326
            # Check if tree inventory has any entries. If so, we populate
 
2327
            # existing_files with the directory content. If there are no
 
2328
            # entries we skip populating existing_files as its not used.
 
2329
            # This improves performance and unncessary work on large
 
2330
            # directory trees. (#501307)
 
2331
            tree_entries = tree.inventory.iter_entries_by_dir()
 
2332
            walk_tree = False
 
2333
            try:
 
2334
                tree_entries = itertools.chain([tree_entries.next()],
 
2335
                    tree_entries)
 
2336
                walk_tree = True
 
2337
            except StopIteration:
 
2338
                pass
 
2339
            if walk_tree:
2325
2340
                existing_files = set()
2326
2341
                for dir, files in wt.walkdirs():
2327
2342
                    existing_files.update(f[0] for f in files)
2328
 
            for num, (tree_path, entry) in tree_entries:
 
2343
            for num, (tree_path, entry) in enumerate(tree_entries):
2329
2344
                pb.update("Building tree", num - len(deferred_contents), total)
2330
2345
                if entry.parent_id is None:
2331
2346
                    continue