~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/inventory.py

  • Committer: Martin Pool
  • Date: 2006-08-15 13:19:12 UTC
  • mfrom: (1923 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1925.
  • Revision ID: mbp@sourcefrog.net-20060815131912-7bbc6d387bb32d16
[merge] bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
865
865
        # root id. Rather than generating a random one here.
866
866
        #if root_id is None:
867
867
        #    root_id = bzrlib.branch.gen_file_id('TREE_ROOT')
868
 
        self.root = InventoryDirectory(root_id, '', None)
 
868
        if root_id is not None:
 
869
            self._set_root(InventoryDirectory(root_id, '', None))
 
870
        else:
 
871
            self.root = None
 
872
            self._byid = {}
869
873
        # FIXME: this isn't ever used, changing it to self.revision may break
870
874
        # things. TODO make everything use self.revision_id
871
875
        self.revision_id = revision_id
 
876
 
 
877
    def _set_root(self, ie):
 
878
        self.root = ie
872
879
        self._byid = {self.root.file_id: self.root}
873
880
 
874
881
    def copy(self):
1046
1053
        if entry.file_id in self._byid:
1047
1054
            raise BzrError("inventory already contains entry with id {%s}" % entry.file_id)
1048
1055
 
1049
 
        if entry.parent_id == ROOT_ID or entry.parent_id is None:
 
1056
        if entry.parent_id is None:
 
1057
            assert self.root is None and len(self._byid) == 0
 
1058
            self._set_root(entry)
 
1059
            return entry
 
1060
        if entry.parent_id == ROOT_ID:
 
1061
            assert self.root is not None, self
1050
1062
            entry.parent_id = self.root.file_id
1051
1063
 
1052
1064
        try: