~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/inventory.py

  • Committer: Martin Pool
  • Date: 2006-02-22 04:29:54 UTC
  • mfrom: (1566 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1569.
  • Revision ID: mbp@sourcefrog.net-20060222042954-60333f08dd56a646
[merge] from bzr.dev before integration
Fix undefined ordering in sign_my_revisions breaking tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
407
407
        # first requested, or preload them if they're already known
408
408
        pass            # nothing to do by default
409
409
 
 
410
    def _forget_tree_state(self):
 
411
        pass
 
412
 
410
413
 
411
414
class RootEntry(InventoryEntry):
412
415
 
570
573
        self.text_sha1 = work_tree.get_file_sha1(self.file_id)
571
574
        self.executable = work_tree.is_executable(self.file_id)
572
575
 
 
576
    def _forget_tree_state(self):
 
577
        self.text_sha1 = None
 
578
        self.executable = None
 
579
 
573
580
    def _snapshot_text(self, file_parents, work_tree, weave_store, transaction):
574
581
        """See InventoryEntry._snapshot_text."""
575
582
        mutter('storing file {%s} in revision {%s}',
679
686
        """See InventoryEntry._read_tree_state."""
680
687
        self.symlink_target = work_tree.get_symlink_target(self.file_id)
681
688
 
 
689
    def _forget_tree_state(self):
 
690
        self.symlink_target = None
 
691
 
682
692
    def _unchanged(self, previous_ie):
683
693
        """See InventoryEntry._unchanged."""
684
694
        compatible = super(InventoryLink, self)._unchanged(previous_ie)
893
903
        from bzrlib.workingtree import gen_file_id
894
904
        
895
905
        parts = bzrlib.osutils.splitpath(relpath)
896
 
        if len(parts) == 0:
897
 
            raise BzrError("cannot re-add root of inventory")
898
906
 
899
907
        if file_id == None:
900
908
            file_id = gen_file_id(relpath)
901
909
 
902
 
        parent_path = parts[:-1]
903
 
        parent_id = self.path2id(parent_path)
904
 
        if parent_id == None:
905
 
            raise NotVersionedError(path=parent_path)
 
910
        if len(parts) == 0:
 
911
            self.root = RootEntry(file_id)
 
912
            self._byid = {self.root.file_id: self.root}
 
913
            return
 
914
        else:
 
915
            parent_path = parts[:-1]
 
916
            parent_id = self.path2id(parent_path)
 
917
            if parent_id == None:
 
918
                raise NotVersionedError(path=parent_path)
906
919
        if kind == 'directory':
907
920
            ie = InventoryDirectory(file_id, parts[-1], parent_id)
908
921
        elif kind == 'file':
928
941
        """
929
942
        ie = self[file_id]
930
943
 
931
 
        assert self[ie.parent_id].children[ie.name] == ie
 
944
        assert ie.parent_id is None or \
 
945
            self[ie.parent_id].children[ie.name] == ie
932
946
        
933
 
        # TODO: Test deleting all children; maybe hoist to a separate
934
 
        # deltree method?
935
 
        if ie.kind == 'directory':
936
 
            for cie in ie.children.values():
937
 
                del self[cie.file_id]
938
 
            del ie.children
939
 
 
940
947
        del self._byid[file_id]
941
 
        del self[ie.parent_id].children[ie.name]
 
948
        if ie.parent_id is not None:
 
949
            del self[ie.parent_id].children[ie.name]
942
950
 
943
951
 
944
952
    def __eq__(self, other):