~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree_4.py

Minor improvements to DirStateRevisionTree.walkdirs()

Show diffs side-by-side

added added

removed removed

Lines of Context:
898
898
        # TODO: jam 20070215 This is the cheap way by cheating and using the
899
899
        #       RevisionTree implementation.
900
900
        #       This should be cleaned up to use the much faster Dirstate code
 
901
        #       This is a little tricky, though, because the dirstate is
 
902
        #       indexed by current path, not by parent path.
 
903
        #       So for now, we just build up the parent inventory, and extract
 
904
        #       it the same way RevisionTree does.
901
905
        _directory = 'directory'
902
 
        inv = self.inventory
 
906
        inv = self._get_inventory()
903
907
        top_id = inv.path2id(prefix)
904
908
        if top_id is None:
905
909
            pending = []
906
910
        else:
907
 
            pending = [(prefix, '', _directory, None, top_id, None)]
 
911
            pending = [(prefix, top_id)]
908
912
        while pending:
909
913
            dirblock = []
910
 
            currentdir = pending.pop()
911
 
            # 0 - relpath, 1- basename, 2- kind, 3- stat, id, v-kind
912
 
            if currentdir[0]:
913
 
                relroot = currentdir[0] + '/'
 
914
            relpath, file_id = pending.pop()
 
915
            # 0 - relpath, 1- file-id
 
916
            if relpath:
 
917
                relroot = relpath + '/'
914
918
            else:
915
919
                relroot = ""
916
920
            # FIXME: stash the node in pending
917
 
            entry = inv[currentdir[4]]
 
921
            entry = inv[file_id]
918
922
            for name, child in entry.sorted_children():
919
923
                toppath = relroot + name
920
924
                dirblock.append((toppath, name, child.kind, None,
921
925
                    child.file_id, child.kind
922
926
                    ))
923
 
            yield (currentdir[0], entry.file_id), dirblock
 
927
            yield (relpath, entry.file_id), dirblock
924
928
            # push the user specified dirs from dirblock
925
929
            for dir in reversed(dirblock):
926
930
                if dir[2] == _directory:
927
 
                    pending.append(dir)
 
931
                    pending.append((dir[0], dir[4]))