~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to read_changeset.py

  • Committer: Aaron Bentley
  • Date: 2005-07-15 19:00:27 UTC
  • mto: (0.5.85)
  • mto: This revision was merged to the branch mainline in revision 1738.
  • Revision ID: abentley@panoramicfeedback.com-20050715190027-60b72a90490baa4c
Fleshed out MockTree, fixed all test failures

Show diffs side-by-side

added added

removed removed

Lines of Context:
547
547
            if info[1][:3] == '=> ':
548
548
                new_path = decode(info[1][3:])
549
549
            else:
550
 
                new_path = decode(info[1][3:])
 
550
                new_path = decode(info[1])
551
551
 
552
552
            file_id = tree.path2id(new_path)
553
553
            if len(info) > 2:
554
554
                text_id = get_text_id(info[2], file_id, kind)
555
555
            else:
556
556
                text_id = get_text_id(None, file_id, kind)
557
 
            tree.note_rename(old_path, new_path, text_id)
 
557
            tree.note_rename(old_path, new_path)
558
558
            if lines:
559
559
                tree.note_patch(new_path, ''.join(lines), text_id)
560
560
 
694
694
    def old_path(self, new_path):
695
695
        """Get the old_path (path in the base_tree) for the file at new_path"""
696
696
        import os.path
 
697
        assert new_path[:1] not in ('\\', '/')
697
698
        old_path = self._renamed.get(new_path)
698
699
        if old_path is not None:
699
700
            return old_path
720
721
        in the base tree.
721
722
        """
722
723
        import os.path
 
724
        assert old_path[:1] not in ('\\', '/')
723
725
        new_path = self._renamed_r.get(old_path)
724
726
        if new_path is not None:
725
727
            return new_path
775
777
                should always either return None or file_id. Even if
776
778
                you are doing the by-path lookup, you are doing a
777
779
                id2path lookup, just to do the reverse path2id lookup.
 
780
 
 
781
        Notice that you're doing the path2id on a different tree!
778
782
        """
779
783
        if self.contents_by_id:
780
784
            if self.base_tree.has_id(file_id):
808
812
        return self.base_tree.inventory[file_id].kind
809
813
 
810
814
    def get_text_id(self, file_id):
 
815
        if self.get_kind(file_id) in ('root_directory', 'directory'):
 
816
            return None
811
817
        if file_id in self._text_ids:
812
818
            return self._text_ids[file_id]
813
819
        return self.base_tree.inventory[file_id].text_id
876
882
                raise BzrError('Got a text_size of None for file_id %r' % file_id)
877
883
            inv.add(ie)
878
884
 
879
 
        for path, ie in base_inv.iter_entries():
880
 
            add_entry(ie.file_id)
881
 
        for file_id in self._new_id_r.iterkeys():
882
 
            if file_id in inv:
 
885
        sorted_entries = self.sorted_path_id()
 
886
        for path, file_id in sorted_entries:
 
887
            if file_id == inv.root.file_id:
883
888
                continue
884
 
            path = self.id2path(file_id)
885
 
            parent_path = dirname(path)
886
 
            if parent_path != '':
887
 
                parent_id = self.path2id(parent_path)
888
 
                if parent_id not in inv:
889
 
                    add_entry(parent_id)
890
 
 
891
889
            add_entry(file_id)
892
890
 
893
891
        return inv
903
901
        for path, entry in self.inventory.iter_entries():
904
902
            yield entry.file_id
905
903
 
 
904
    def sorted_path_id(self):
 
905
        paths = []
 
906
        for result in self._new_id.iteritems():
 
907
            paths.append(result)
 
908
        for id in self.base_tree:
 
909
            path = self.id2path(id)
 
910
            if path is None:
 
911
                continue
 
912
            paths.append((path, id))
 
913
        paths.sort()
 
914
        return paths
 
915
 
906
916
 
907
917
def patched_file(file_patch, original):
908
918
    from bzrlib.patch import patch