~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/inventory.py

Add a new method ``Tree.revision_tree`` which allows access to cached
trees for arbitrary revisions. This allows the in development dirstate
tree format to provide access to the callers to cached copies of 
inventory data which are cheaper to access than inventories from the
repository. (Robert Collins, Martin Pool)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1217
1217
    def has_id(self, file_id):
1218
1218
        return (file_id in self._byid)
1219
1219
 
 
1220
    def remove_recursive_id(self, file_id):
 
1221
        """Remove file_id, and children, from the inventory.
 
1222
        
 
1223
        :param file_id: A file_id to remove.
 
1224
        """
 
1225
        to_find_delete = [self._byid[file_id]]
 
1226
        to_delete = []
 
1227
        while to_find_delete:
 
1228
            ie = to_find_delete.pop()
 
1229
            to_delete.append(ie.file_id)
 
1230
            if ie.kind == 'directory':
 
1231
                to_find_delete.extend(ie.children.values())
 
1232
        for file_id in reversed(to_delete):
 
1233
            ie = self[file_id]
 
1234
            del self._byid[file_id]
 
1235
            if ie.parent_id is not None:
 
1236
                del self[ie.parent_id].children[ie.name]
 
1237
 
1220
1238
    def rename(self, file_id, new_parent_id, new_name):
1221
1239
        """Move a file within the inventory.
1222
1240