~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/inventory.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-06-03 00:49:18 UTC
  • mfrom: (4398.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090603004918-k6xr5guhlh4f2dd7
(igc) make recursion optional in iter-entries()

Show diffs side-by-side

added added

removed removed

Lines of Context:
747
747
            [parent.name for parent in
748
748
             self._iter_file_id_parents(file_id)][:-1]))
749
749
 
750
 
    def iter_entries(self, from_dir=None):
751
 
        """Return (path, entry) pairs, in order by name."""
 
750
    def iter_entries(self, from_dir=None, recursive=True):
 
751
        """Return (path, entry) pairs, in order by name.
 
752
        
 
753
        :param from_dir: if None, start from the root,
 
754
          otherwise start from this directory (either file-id or entry)
 
755
        :param recursive: recurse into directories or not
 
756
        """
752
757
        if from_dir is None:
753
758
            if self.root is None:
754
759
                return
761
766
        # 440ms/663ms (inline/total) to 116ms/116ms
762
767
        children = from_dir.children.items()
763
768
        children.sort()
 
769
        if not recursive:
 
770
            for name, ie in children:
 
771
                yield name, ie
 
772
            return
764
773
        children = collections.deque(children)
765
774
        stack = [(u'', children)]
766
775
        while stack: