~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bundle/read_bundle.py

Roundtrip tree roots in bundles

Show diffs side-by-side

added added

removed removed

Lines of Context:
647
647
        self.revision_id = revision_id
648
648
        self._inventory = None
649
649
 
 
650
    @staticmethod
 
651
    def _true_path(path):
 
652
        if path != '.':
 
653
            return path
 
654
        else:
 
655
            return ''
 
656
 
650
657
    def __str__(self):
651
658
        return pprint.pformat(self.__dict__)
652
659
 
653
660
    def note_rename(self, old_path, new_path):
654
661
        """A file/directory has been renamed from old_path => new_path"""
 
662
        new_path = self._true_path(new_path)
 
663
        old_path = self._true_path(old_path)
655
664
        assert not self._renamed.has_key(new_path)
656
665
        assert not self._renamed_r.has_key(old_path)
657
666
        self._renamed[new_path] = old_path
659
668
 
660
669
    def note_id(self, new_id, new_path, kind='file'):
661
670
        """Files that don't exist in base need a new id."""
 
671
        new_path = self._true_path(new_path)
662
672
        self._new_id[new_path] = new_id
663
673
        self._new_id_r[new_id] = new_path
664
674
        self._kinds[new_id] = kind
674
684
 
675
685
    def note_patch(self, new_path, patch):
676
686
        """There is a patch for a given filename."""
677
 
        self.patches[new_path] = patch
 
687
        self.patches[self._true_path(new_path)] = patch
678
688
 
679
689
    def note_target(self, new_path, target):
680
690
        """The symlink at the new path has the given target"""
681
 
        self._targets[new_path] = target
 
691
        self._targets[self._true_path(new_path)] = target
682
692
 
683
693
    def note_deletion(self, old_path):
684
694
        """The file at old_path has been deleted."""
685
 
        self.deleted.append(old_path)
 
695
        self.deleted.append(self._true_path(old_path))
686
696
 
687
697
    def note_executable(self, new_path, executable):
688
 
        self._executable[new_path] = executable
 
698
        self._executable[self._true_path(new_path)] = executable
689
699
 
690
700
    def old_path(self, new_path):
691
701
        """Get the old_path (path in the base_tree) for the file at new_path"""
 
702
        new_path = self._true_path(new_path)
692
703
        assert new_path[:1] not in ('\\', '/')
693
704
        old_path = self._renamed.get(new_path)
694
705
        if old_path is not None:
715
726
        """Get the new_path (path in the target_tree) for the file at old_path
716
727
        in the base tree.
717
728
        """
 
729
        old_path = self._true_path(old_path)
718
730
        assert old_path[:1] not in ('\\', '/')
719
731
        new_path = self._renamed_r.get(old_path)
720
732
        if new_path is not None:
821
833
 
822
834
    def get_last_changed(self, file_id):
823
835
        path = self.id2path(file_id)
 
836
        if path == '':
 
837
            return None
824
838
        if path in self._last_changed:
825
839
            return self._last_changed[path]
826
840
        return self.base_tree.inventory[file_id].revision
857
871
        if base_inv.root is not None:
858
872
            root_id = base_inv.root.file_id
859
873
        try:
 
874
            root_id = self._new_id['']
 
875
        except KeyError:
 
876
            pass
 
877
        try:
860
878
            # New inventories have a unique root_id
861
879
            inv = Inventory(root_id, self.revision_id)
862
880
        except TypeError: