~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/weave.py

  • Committer: Robert Collins
  • Date: 2005-10-06 12:14:01 UTC
  • mfrom: (1393.1.67)
  • Revision ID: robertc@robertcollins.net-20051006121401-ce87bcb93909bbdf
merge martins latest

Show diffs side-by-side

added added

removed removed

Lines of Context:
805
805
 
806
806
    def _check_version_consistent(self, other, other_idx, name):
807
807
        """Check if a version in consistent in this and other.
 
808
 
 
809
        To be consistent it must have:
 
810
 
 
811
         * the same text
 
812
         * the same direct parents (by name, not index, and disregarding
 
813
           order)
808
814
        
809
815
        If present & correct return True;
810
816
        if not present in self return False; 
812
818
        this_idx = self._name_map.get(name, -1)
813
819
        if this_idx != -1:
814
820
            if self._sha1s[this_idx] != other._sha1s[other_idx]:
815
 
                raise WeaveError("inconsistent texts for version {%s} in %r and %r"
816
 
                                 % (name, self, other))
817
 
            elif set(self._parents[this_idx]) != set(other._parents[other_idx]):
818
 
                raise WeaveError("inconsistent parents for version {%s} in %r and %r"
819
 
                                 % (name, self, other))
 
821
                raise WeaveError("inconsistent texts for version {%s} "
 
822
                                 "when joining weaves"
 
823
                                 % (name))
 
824
            self_parents = self._parents[this_idx]
 
825
            other_parents = other._parents[other_idx]
 
826
            n1 = [self._names[i] for i in self_parents]
 
827
            n2 = [other._names[i] for i in other_parents]
 
828
            n1.sort()
 
829
            n2.sort()
 
830
            if n1 != n2:
 
831
                raise WeaveError("inconsistent parents for version {%s}: "
 
832
                                 "%s vs %s"
 
833
                                 % (name, n1, n2))
820
834
            else:
821
835
                return True         # ok!
822
836
        else: