~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/inventory.py

Got real root moves working

Show diffs side-by-side

added added

removed removed

Lines of Context:
893
893
        from bzrlib.workingtree import gen_file_id
894
894
        
895
895
        parts = bzrlib.osutils.splitpath(relpath)
896
 
        if len(parts) == 0:
897
 
            raise BzrError("cannot re-add root of inventory")
898
896
 
899
897
        if file_id == None:
900
898
            file_id = gen_file_id(relpath)
901
899
 
902
 
        parent_path = parts[:-1]
903
 
        parent_id = self.path2id(parent_path)
904
 
        if parent_id == None:
905
 
            raise NotVersionedError(path=parent_path)
 
900
        if len(parts) == 0:
 
901
            self.root = RootEntry(file_id)
 
902
            self._byid = {self.root.file_id: self.root}
 
903
            return
 
904
        else:
 
905
            parent_path = parts[:-1]
 
906
            parent_id = self.path2id(parent_path)
 
907
            if parent_id == None:
 
908
                raise NotVersionedError(path=parent_path)
906
909
        if kind == 'directory':
907
910
            ie = InventoryDirectory(file_id, parts[-1], parent_id)
908
911
        elif kind == 'file':
928
931
        """
929
932
        ie = self[file_id]
930
933
 
931
 
        assert self[ie.parent_id].children[ie.name] == ie
 
934
        assert ie.parent_id is None or \
 
935
            self[ie.parent_id].children[ie.name] == ie
932
936
        
933
937
        del self._byid[file_id]
934
 
        del self[ie.parent_id].children[ie.name]
 
938
        if ie.parent_id is not None:
 
939
            del self[ie.parent_id].children[ie.name]
935
940
 
936
941
 
937
942
    def __eq__(self, other):