~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-07-01 18:46:16 UTC
  • mfrom: (1551.7.9 Aaron's mergeable stuff)
  • Revision ID: pqm@pqm.ubuntu.com-20060701184616-b0b6979d6f86a5a1
bzr revert DIRNAME works recursively

Show diffs side-by-side

added added

removed removed

Lines of Context:
987
987
 
988
988
def find_interesting(working_tree, target_tree, filenames):
989
989
    """Find the ids corresponding to specified filenames."""
 
990
    trees = (working_tree, target_tree)
990
991
    if not filenames:
991
992
        interesting_ids = None
992
993
    else:
993
994
        interesting_ids = set()
994
995
        for tree_path in filenames:
995
996
            not_found = True
996
 
            for tree in (working_tree, target_tree):
 
997
            for tree in trees:
997
998
                file_id = tree.inventory.path2id(tree_path)
998
999
                if file_id is not None:
999
1000
                    interesting_ids.add(file_id)
1000
1001
                    not_found = False
1001
1002
            if not_found:
1002
1003
                raise NotVersionedError(path=tree_path)
 
1004
        
 
1005
        pending = interesting_ids
 
1006
        # now handle children of interesting ids
 
1007
        # we loop so that we handle all children of each id in both trees
 
1008
        while len(pending) > 0:
 
1009
            new_pending = set()
 
1010
            for file_id in pending:
 
1011
                for tree in trees:
 
1012
                    if file_id not in tree:
 
1013
                        continue
 
1014
                    entry = tree.inventory[file_id]
 
1015
                    for child in getattr(entry, 'children', {}).itervalues():
 
1016
                        if child.file_id not in interesting_ids:
 
1017
                            new_pending.add(child.file_id)
 
1018
            interesting_ids.update(new_pending)
 
1019
            pending = new_pending
1003
1020
    return interesting_ids
1004
1021
 
1005
1022