~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/weave.py

  • Committer: Martin Pool
  • Date: 2005-10-05 03:29:44 UTC
  • mto: (1185.13.3)
  • mto: This revision was merged to the branch mainline in revision 1403.
  • Revision ID: mbp@sourcefrog.net-20051005032944-6733675b57f5e971
- add Weave._check_consistent_with 
- weave docs

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
# variant that is passed a pre-cooked version of the single basis
60
60
# version?
61
61
 
 
62
# TODO: Have a way to go back and insert a revision V1 that is a parent 
 
63
# of an already-stored revision V2.  This means some lines previously 
 
64
# counted as new in V2 will be discovered to have actually come from V1.  
 
65
# It is probably necessary to insert V1, then compute a whole new diff 
 
66
# from the mashed ancestors to V2.  This must be repeated for every 
 
67
# direct child of V1.  The deltas from V2 to its descendents won't change,
 
68
# although their location within the weave may change.  It may be possible
 
69
# to just adjust the location of those instructions rather than 
 
70
# re-weaving the whole thing.  This is expected to be a fairly rare
 
71
# operation, only used when inserting data that was previously a ghost.
 
72
 
 
73
 
62
74
 
63
75
 
64
76
import sha
205
217
                             (name, self._weave_name))
206
218
 
207
219
 
 
220
    def iter_names(self):
 
221
        """Yield a list of all names in this weave."""
 
222
        return iter(self._names)
 
223
 
208
224
    def idx_to_name(self, version):
209
225
        return self._names[version]
210
226
 
742
758
    def join(self, other):
743
759
        """Integrate versions from other into this weave.
744
760
 
745
 
        The resulting weave contains all the history of both weaves; any version you 
746
 
        could retrieve from either self or other can be retrieved from self after
747
 
        this call.
 
761
        The resulting weave contains all the history of both weaves; 
 
762
        any version you could retrieve from either self or other can be 
 
763
        retrieved from self after this call.
748
764
 
749
 
        It is illegal for the two weaves to contain different values for any version.
 
765
        It is illegal for the two weaves to contain different values 
 
766
        for any version.
750
767
        """
751
768
        if other.numversions() == 0:
752
769
            return          # nothing to update, easy
 
770
        self._check_consistent_with(other)
753
771
        raise NotImplementedError()
754
772
 
755
773
 
 
774
    def _check_consistent_with(self, other):
 
775
        """Make sure any versions present in both weaves have consistent values."""
 
776
        for name in self._names:
 
777
            if name not in other._names:
 
778
                continue
 
779
            if self._sha1s[self._names[name]] != other._sha1s[other._names[name]]:
 
780
                raise WeaveError("inconsistent texts for version {%s} in %r and %r"
 
781
                                 % name, self, other)
756
782
 
757
783
 
758
784