~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

  • Committer: John Arbash Meinel
  • Date: 2006-07-03 13:48:52 UTC
  • mfrom: (1835 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1836.
  • Revision ID: john@arbash-meinel.com-20060703134852-295eeb195b8e2811
[merge] bzr.dev 1835

Show diffs side-by-side

added added

removed removed

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