~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/changeset.py

  • Committer: Robert Collins
  • Date: 2005-11-28 05:13:41 UTC
  • mfrom: (1185.33.54 merge-recovered)
  • Revision ID: robertc@robertcollins.net-20051128051341-059936f2f29a12c8
Merge from Martin. Adjust check to work with HTTP again.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
from bzrlib.trace import mutter, warning
33
33
from bzrlib.osutils import rename, sha_file
34
34
import bzrlib
 
35
from bzrlib.errors import BzrCheckError
35
36
 
36
37
__docformat__ = "restructuredtext"
37
38
 
632
633
        if self.id  == self.parent:
633
634
            raise ParentIDIsSelf(self)
634
635
 
635
 
    def __str__(self):
 
636
    def __repr__(self):
636
637
        return "ChangesetEntry(%s)" % self.id
637
638
 
 
639
    __str__ = __repr__
 
640
 
638
641
    def __get_dir(self):
639
642
        if self.path is None:
640
643
            return None
749
752
        """
750
753
        orig_path = self.get_cset_path(False)
751
754
        mod_path = self.get_cset_path(True)
752
 
        if orig_path is not None:
 
755
        if orig_path and orig_path.startswith('./'):
753
756
            orig_path = orig_path[2:]
754
 
        if mod_path is not None:
 
757
        if mod_path and mod_path.startswith('./'):
755
758
            mod_path = mod_path[2:]
756
759
        if orig_path == mod_path:
757
760
            return orig_path
795
798
                raise SourceRootHasName(self, to_name)
796
799
            else:
797
800
                return '.'
798
 
        if from_dir == to_dir:
 
801
        parent_entry = changeset.entries.get(parent)
 
802
        if parent_entry is None:
799
803
            dir = os.path.dirname(id_map[self.id])
800
804
        else:
801
805
            mutter("path, new_path: %r %r", self.path, self.new_path)
802
 
            parent_entry = changeset.entries[parent]
803
806
            dir = parent_entry.get_new_path(id_map, changeset, reverse)
804
807
        if from_name == to_name:
805
808
            name = os.path.basename(id_map[self.id])
936
939
            temp_name[entry.id] = None
937
940
 
938
941
        elif entry.needs_rename():
 
942
            if entry.is_creation(reverse):
 
943
                continue
939
944
            to_name = os.path.join(temp_dir, str(i))
940
945
            src_path = inventory.get(entry.id)
941
946
            if src_path is not None:
982
987
            entry.apply(new_path, conflict_handler, reverse)
983
988
            changed_inventory[entry.id] = new_tree_path
984
989
        elif entry.needs_rename():
 
990
            if entry.is_deletion(reverse):
 
991
                continue
985
992
            if old_path is None:
986
993
                continue
987
994
            try:
 
995
                mutter('rename %s to final name %s', old_path, new_path)
988
996
                rename(old_path, new_path)
989
997
                changed_inventory[entry.id] = new_tree_path
990
998
            except OSError, e:
991
 
                raise Exception ("%s is missing" % new_path)
 
999
                raise BzrCheckError('failed to rename %s to %s for changeset entry %s: %s'
 
1000
                        % (old_path, new_path, entry, e))
992
1001
 
993
1002
class TargetExists(Exception):
994
1003
    def __init__(self, entry, target):