~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/inventory.py

  • Committer: Robert Collins
  • Date: 2006-07-21 01:37:47 UTC
  • mto: (1852.9.1 Tree.compare().)
  • mto: This revision was merged to the branch mainline in revision 1890.
  • Revision ID: robertc@robertcollins.net-20060721013747-9752a96bc423aa76
Make iter(Tree) consistent for all tree types.

Show diffs side-by-side

added added

removed removed

Lines of Context:
867
867
 
868
868
    def copy(self):
869
869
        # TODO: jam 20051218 Should copy also copy the revision_id?
870
 
        other = Inventory(self.root.file_id)
 
870
        entries = self.iter_entries()
 
871
        other = Inventory(entries.next()[1].file_id)
871
872
        # copy recursively so we know directories will be added before
872
873
        # their children.  There are more efficient ways than this...
873
 
        for path, entry in self.iter_entries():
874
 
            if entry == self.root:
875
 
                continue
 
874
        for path, entry in entries():
876
875
            other.add(entry.copy())
877
876
        return other
878
877
 
888
887
        if from_dir is None:
889
888
            assert self.root
890
889
            from_dir = self.root
 
890
            yield '', self.root
891
891
        elif isinstance(from_dir, basestring):
892
892
            from_dir = self._byid[from_dir]
893
893