~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/inventory.py

  • Committer: Aaron Bentley
  • Date: 2006-02-22 14:39:42 UTC
  • mto: (2027.1.2 revert-subpath-56549)
  • mto: This revision was merged to the branch mainline in revision 1570.
  • Revision ID: abentley@panoramicfeedback.com-20060222143942-ae72299f2de66767
Fixed build_tree with symlinks

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)
735
745
        The inventory is created with a default root directory, with
736
746
        an id of None.
737
747
        """
738
 
        # We are letting Branch.initialize() create a unique inventory
 
748
        # We are letting Branch.create() create a unique inventory
739
749
        # root id. Rather than generating a random one here.
740
750
        #if root_id is None:
741
751
        #    root_id = bzrlib.branch.gen_file_id('TREE_ROOT')
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):