~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/revisiontree.py

  • Committer: Robert Collins
  • Date: 2006-07-29 03:57:49 UTC
  • mto: (1852.14.2 status-benchmarks)
  • mto: This revision was merged to the branch mainline in revision 2322.
  • Revision ID: robertc@robertcollins.net-20060729035749-f4d52d3fcc448fd9
Add a first-cut Tree.walkdirs method.

Show diffs side-by-side

added added

removed removed

Lines of Context:
113
113
    def unlock(self):
114
114
        self._repository.unlock()
115
115
 
116
 
 
 
116
    def walkdirs(self, prefix=""):
 
117
        _directory = 'directory'
 
118
        pending = [('', '', _directory, None, '', None, None)]
 
119
        inv = self.inventory
 
120
        while pending:
 
121
            dirblock = []
 
122
            currentdir = pending.pop()
 
123
            # 0 - relpath, 1- basename, 2- kind, 3- stat, 4-toppath
 
124
            top = currentdir[4]
 
125
            if currentdir[0]:
 
126
                relroot = currentdir[0] + '/'
 
127
            else:
 
128
                relroot = ""
 
129
            # FIXME: stash the node in pending
 
130
            entry = inv[inv.path2id(top)]
 
131
            for name, child in entry.sorted_children():
 
132
                toppath = relroot + name
 
133
                dirblock.append((toppath, name, child.kind, None, toppath,
 
134
                    child.file_id, child.kind
 
135
                    ))
 
136
            yield (currentdir[0], top, entry.file_id), dirblock
 
137
            # push the user specified dirs from dirblock
 
138
            for dir in reversed(dirblock):
 
139
                if dir[2] == _directory:
 
140
                    pending.append(dir)
 
141