~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/weave.py

  • Committer: Jelmer Vernooij
  • Date: 2011-01-19 20:09:12 UTC
  • mto: (5582.10.33 weave-fmt-plugin)
  • mto: This revision was merged to the branch mainline in revision 5625.
  • Revision ID: jelmer@samba.org-20110119200912-dm3hbp7dxqg7isbp
remove some of the weave changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
78
78
    errors,
79
79
    osutils,
80
80
    )
81
 
from bzrlib.errors import (
82
 
    BzrError,
83
 
    ParentMismatch,
84
 
    RevisionAlreadyPresent,
85
 
    RevisionNotPresent,
86
 
    UnavailableRepresentation,
87
 
    )
88
 
from bzrlib.osutils import (
89
 
    dirname,
90
 
    sha,
91
 
    sha_strings,
92
 
    split_lines,
93
 
    )
 
81
from bzrlib.errors import (WeaveError, WeaveFormatError, WeaveParentMismatch,
 
82
        RevisionAlreadyPresent,
 
83
        RevisionNotPresent,
 
84
        UnavailableRepresentation,
 
85
        )
 
86
from bzrlib.osutils import dirname, sha, sha_strings, split_lines
94
87
import bzrlib.patiencediff
95
88
from bzrlib.revision import NULL_REVISION
96
89
from bzrlib.symbol_versioning import *
105
98
from bzrlib.weavefile import _read_weave_v5, write_weave_v5
106
99
 
107
100
 
108
 
class WeaveError(BzrError):
109
 
 
110
 
    _fmt = "Error in processing weave: %(msg)s"
111
 
 
112
 
    def __init__(self, msg=None):
113
 
        BzrError.__init__(self)
114
 
        self.msg = msg
115
 
 
116
 
 
117
 
class WeaveRevisionNotPresent(WeaveError):
118
 
 
119
 
    _fmt = "Revision {%(revision_id)s} not present in %(weave)s"
120
 
 
121
 
    def __init__(self, revision_id, weave):
122
 
        WeaveError.__init__(self)
123
 
        self.revision_id = revision_id
124
 
        self.weave = weave
125
 
 
126
 
 
127
 
class WeaveFormatError(WeaveError):
128
 
 
129
 
    _fmt = "Weave invariant violated: %(what)s"
130
 
 
131
 
    def __init__(self, what):
132
 
        WeaveError.__init__(self)
133
 
        self.what = what
134
 
 
135
 
 
136
 
class WeaveTextDiffers(WeaveError):
137
 
 
138
 
    _fmt = ("Weaves differ on text content. Revision:"
139
 
            " {%(revision_id)s}, %(weave_a)s, %(weave_b)s")
140
 
 
141
 
    def __init__(self, revision_id, weave_a, weave_b):
142
 
        WeaveError.__init__(self)
143
 
        self.revision_id = revision_id
144
 
        self.weave_a = weave_a
145
 
        self.weave_b = weave_b
146
 
 
147
 
 
148
101
class WeaveContentFactory(ContentFactory):
149
102
    """Content factory for streaming from weaves.
150
103
 
809
762
        expected_sha1 = self._sha1s[int_index]
810
763
        measured_sha1 = sha_strings(result)
811
764
        if measured_sha1 != expected_sha1:
812
 
            raise errors.VersionedFileInvalidChecksum(
 
765
            raise errors.WeaveInvalidChecksum(
813
766
                    'file %s, revision %s, expected: %s, measured %s'
814
767
                    % (self._weave_name, version_id,
815
768
                       expected_sha1, measured_sha1))
886
839
            hd = sha1s[version].hexdigest()
887
840
            expected = self._sha1s[i]
888
841
            if hd != expected:
889
 
                raise errors.VersionedFileInvalidChecksum(
 
842
                raise errors.WeaveInvalidChecksum(
890
843
                        "mismatched sha1 for version %s: "
891
844
                        "got %s, expected %s"
892
845
                        % (version, hd, expected))
928
881
            n1 = set([self._names[i] for i in self_parents])
929
882
            n2 = set([other._names[i] for i in other_parents])
930
883
            if not self._compatible_parents(n1, n2):
931
 
                raise ParentMismatch(name, n1, n2)
 
884
                raise WeaveParentMismatch("inconsistent parents "
 
885
                    "for version {%s}: %s vs %s" % (name, n1, n2))
932
886
            else:
933
887
                return True         # ok!
934
888
        else: