~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/inventory.py

Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
865
865
        an id of None.
866
866
        """
867
867
        if root_id is not None:
868
 
            self.root = InventoryDirectory(root_id, '', None)
869
 
            self._byid = {self.root.file_id: self.root}
 
868
            self._set_root(InventoryDirectory(root_id, '', None))
870
869
        else:
871
870
            self.root = None
872
871
            self._byid = {}
873
872
        self.revision_id = revision_id
874
873
 
 
874
    def _set_root(self, ie):
 
875
        self.root = ie
 
876
        self._byid = {self.root.file_id: self.root}
 
877
 
875
878
    def copy(self):
876
879
        # TODO: jam 20051218 Should copy also copy the revision_id?
877
880
        entries = self.iter_entries()
1049
1052
            raise BzrError("inventory already contains entry with id {%s}" % entry.file_id)
1050
1053
 
1051
1054
        if entry.parent_id is None:
1052
 
            entry.parent_id = self.root.file_id
1053
 
 
 
1055
            assert self.root is None and len(self._byid) == 0
 
1056
            self._set_root(entry)
 
1057
            return entry
1054
1058
        try:
1055
1059
            parent = self._byid[entry.parent_id]
1056
1060
        except KeyError: