~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tree.py

  • Committer: Patch Queue Manager
  • Date: 2012-04-02 02:36:45 UTC
  • mfrom: (6471.1.7 iter-child-entries)
  • Revision ID: pqm@pqm.ubuntu.com-20120402023645-28dkcb0awh3i1flc
(jelmer) Add Tree.iter_child_entries(). (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
195
195
        """
196
196
        raise NotImplementedError(self.iter_entries_by_dir)
197
197
 
 
198
    def iter_child_entries(self, file_id, path=None):
 
199
        """Iterate over the children of a directory or tree reference.
 
200
 
 
201
        :param file_id: File id of the directory/tree-reference
 
202
        :param path: Optional path of the directory
 
203
        :raise NoSuchId: When the file_id does not exist
 
204
        :return: Iterator over entries in the directory
 
205
        """
 
206
        raise NotImplementedError(self.iter_child_entries)
 
207
 
198
208
    def list_files(self, include_root=False, from_dir=None, recursive=True):
199
209
        """List all files in this tree.
200
210
 
871
881
        return self.root_inventory.iter_entries_by_dir(
872
882
            specific_file_ids=inventory_file_ids, yield_parents=yield_parents)
873
883
 
 
884
    @needs_read_lock
 
885
    def iter_child_entries(self, file_id, path=None):
 
886
        inv, inv_file_id = self._unpack_file_id(file_id)
 
887
        return inv[inv_file_id].children.itervalues()
 
888
 
874
889
    @deprecated_method(deprecated_in((2, 5, 0)))
875
890
    def get_file_by_path(self, path):
876
891
        return self.get_file(self.path2id(path), path)
1344
1359
                        if old_entry is None:
1345
1360
                            # Reusing a discarded change.
1346
1361
                            old_entry = self._get_entry(self.source, file_id)
1347
 
                        for child in self.source.iter_children(file_id):
1348
 
                            precise_file_ids.add(child)
 
1362
                        precise_file_ids.update(
 
1363
                                self.source.iter_children(file_id))
1349
1364
                    changed_file_ids.add(result[0])
1350
1365
                    yield result
1351
1366