Mercurial > hg
comparison tests/simplestorerepo.py @ 39777:b63dee7bd0d9
global: replace most uses of RevlogError with StorageError (API)
When catching errors in storage, we should be catching
StorageError instead of RevlogError. When throwing errors related
to storage, we shouldn't be using RevlogError unless we know
the error stemmed from revlogs. And we only reliably know that
if we're in revlog.py or are inheriting from a type defined in
revlog.py.
Differential Revision: https://phab.mercurial-scm.org/D4655
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Tue, 18 Sep 2018 16:47:09 -0700 |
parents | 2cd93a8d4bde |
children | 979e9f124caa |
comparison
equal
deleted
inserted
replaced
39776:cb65d4b7e429 | 39777:b63dee7bd0d9 |
---|---|
59 | 59 |
60 def validaterev(rev): | 60 def validaterev(rev): |
61 if not isinstance(rev, int): | 61 if not isinstance(rev, int): |
62 raise ValueError('expected int') | 62 raise ValueError('expected int') |
63 | 63 |
64 class simplestoreerror(error.StorageError): | |
65 pass | |
66 | |
64 @interfaceutil.implementer(repository.irevisiondelta) | 67 @interfaceutil.implementer(repository.irevisiondelta) |
65 @attr.s(slots=True, frozen=True) | 68 @attr.s(slots=True, frozen=True) |
66 class simplestorerevisiondelta(object): | 69 class simplestorerevisiondelta(object): |
67 node = attr.ib() | 70 node = attr.ib() |
68 p1node = attr.ib() | 71 p1node = attr.ib() |
259 def _processflags(self, text, flags, operation, raw=False): | 262 def _processflags(self, text, flags, operation, raw=False): |
260 if flags == 0: | 263 if flags == 0: |
261 return text, True | 264 return text, True |
262 | 265 |
263 if flags & ~revlog.REVIDX_KNOWN_FLAGS: | 266 if flags & ~revlog.REVIDX_KNOWN_FLAGS: |
264 raise error.RevlogError(_("incompatible revision flag '%#x'") % | 267 raise simplestoreerror(_("incompatible revision flag '%#x'") % |
265 (flags & ~revlog.REVIDX_KNOWN_FLAGS)) | 268 (flags & ~revlog.REVIDX_KNOWN_FLAGS)) |
266 | 269 |
267 validatehash = True | 270 validatehash = True |
268 # Depending on the operation (read or write), the order might be | 271 # Depending on the operation (read or write), the order might be |
269 # reversed due to non-commutative transforms. | 272 # reversed due to non-commutative transforms. |
270 orderedflags = revlog.REVIDX_FLAGS_ORDER | 273 orderedflags = revlog.REVIDX_FLAGS_ORDER |
277 if flag & flags: | 280 if flag & flags: |
278 vhash = True | 281 vhash = True |
279 | 282 |
280 if flag not in revlog._flagprocessors: | 283 if flag not in revlog._flagprocessors: |
281 message = _("missing processor for flag '%#x'") % (flag) | 284 message = _("missing processor for flag '%#x'") % (flag) |
282 raise error.RevlogError(message) | 285 raise simplestoreerror(message) |
283 | 286 |
284 processor = revlog._flagprocessors[flag] | 287 processor = revlog._flagprocessors[flag] |
285 if processor is not None: | 288 if processor is not None: |
286 readtransform, writetransform, rawtransform = processor | 289 readtransform, writetransform, rawtransform = processor |
287 | 290 |
297 | 300 |
298 def checkhash(self, text, node, p1=None, p2=None, rev=None): | 301 def checkhash(self, text, node, p1=None, p2=None, rev=None): |
299 if p1 is None and p2 is None: | 302 if p1 is None and p2 is None: |
300 p1, p2 = self.parents(node) | 303 p1, p2 = self.parents(node) |
301 if node != revlog.hash(text, p1, p2): | 304 if node != revlog.hash(text, p1, p2): |
302 raise error.RevlogError(_("integrity check failed on %s") % | 305 raise simplestoreerror(_("integrity check failed on %s") % |
303 self._path) | 306 self._path) |
304 | 307 |
305 def revision(self, node, raw=False): | 308 def revision(self, node, raw=False): |
306 validatenode(node) | 309 validatenode(node) |
307 | 310 |