~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/inventory.py

  • Committer: Andrew Bennetts
  • Date: 2009-06-09 03:14:05 UTC
  • mfrom: (4416 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4420.
  • Revision ID: andrew.bennetts@canonical.com-20090609031405-wak9yogzzpx9o172
Merge bzr.dev, resolving NEWS conflict.

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:
1547
1556
    def _get_mutable_inventory(self):
1548
1557
        """See CommonInventory._get_mutable_inventory."""
1549
1558
        entries = self.iter_entries()
1550
 
        if self.root_id is not None:
1551
 
            entries.next()
1552
 
        inv = Inventory(self.root_id, self.revision_id)
 
1559
        inv = Inventory(None, self.revision_id)
1553
1560
        for path, inv_entry in entries:
1554
 
            inv.add(inv_entry)
 
1561
            inv.add(inv_entry.copy())
1555
1562
        return inv
1556
1563
 
1557
1564
    def create_by_apply_delta(self, inventory_delta, new_revision_id,