##// END OF EJS Templates
global: replace most uses of RevlogError with StorageError (API)...
Gregory Szorc -
r39813:b63dee7b default
parent child Browse files
Show More
@@ -586,7 +586,7 b' def remote(repo, remote=None):'
586 raise error.Abort(_('lfs: unknown url scheme: %s') % scheme)
586 raise error.Abort(_('lfs: unknown url scheme: %s') % scheme)
587 return _storemap[scheme](repo, url)
587 return _storemap[scheme](repo, url)
588
588
589 class LfsRemoteError(error.RevlogError):
589 class LfsRemoteError(error.StorageError):
590 pass
590 pass
591
591
592 class LfsCorruptionError(error.Abort):
592 class LfsCorruptionError(error.Abort):
@@ -19,7 +19,7 b' from mercurial.utils import ('
19 stringutil,
19 stringutil,
20 )
20 )
21
21
22 class InvalidPointer(error.RevlogError):
22 class InvalidPointer(error.StorageError):
23 pass
23 pass
24
24
25 class gitlfspointer(dict):
25 class gitlfspointer(dict):
@@ -503,7 +503,7 b' class transplanter(object):'
503 def hasnode(repo, node):
503 def hasnode(repo, node):
504 try:
504 try:
505 return repo.changelog.rev(node) is not None
505 return repo.changelog.rev(node) is not None
506 except error.RevlogError:
506 except error.StorageError:
507 return False
507 return False
508
508
509 def browserevs(ui, repo, nodes, opts):
509 def browserevs(ui, repo, nodes, opts):
@@ -513,10 +513,10 b' class changelog(revlog.revlog):'
513 # revision text contain two "\n\n" sequences -> corrupt
513 # revision text contain two "\n\n" sequences -> corrupt
514 # repository since read cannot unpack the revision.
514 # repository since read cannot unpack the revision.
515 if not user:
515 if not user:
516 raise error.RevlogError(_("empty username"))
516 raise error.StorageError(_("empty username"))
517 if "\n" in user:
517 if "\n" in user:
518 raise error.RevlogError(_("username %r contains a newline")
518 raise error.StorageError(_("username %r contains a newline")
519 % pycompat.bytestr(user))
519 % pycompat.bytestr(user))
520
520
521 desc = stripdesc(desc)
521 desc = stripdesc(desc)
522
522
@@ -529,8 +529,8 b' class changelog(revlog.revlog):'
529 if branch in ("default", ""):
529 if branch in ("default", ""):
530 del extra["branch"]
530 del extra["branch"]
531 elif branch in (".", "null", "tip"):
531 elif branch in (".", "null", "tip"):
532 raise error.RevlogError(_('the name \'%s\' is reserved')
532 raise error.StorageError(_('the name \'%s\' is reserved')
533 % branch)
533 % branch)
534 if extra:
534 if extra:
535 extra = encodeextra(extra)
535 extra = encodeextra(extra)
536 parseddate = "%s %s" % (parseddate, extra)
536 parseddate = "%s %s" % (parseddate, extra)
@@ -283,7 +283,7 b' class PushkeyFailed(Abort):'
283 Abort.__init__(self, 'failed to update value for "%s/%s"'
283 Abort.__init__(self, 'failed to update value for "%s/%s"'
284 % (namespace, key))
284 % (namespace, key))
285
285
286 class CensoredNodeError(RevlogError):
286 class CensoredNodeError(StorageError):
287 """error raised when content verification fails on a censored node
287 """error raised when content verification fails on a censored node
288
288
289 Also contains the tombstone data substituted for the uncensored data.
289 Also contains the tombstone data substituted for the uncensored data.
@@ -291,10 +291,10 b' class CensoredNodeError(RevlogError):'
291
291
292 def __init__(self, filename, node, tombstone):
292 def __init__(self, filename, node, tombstone):
293 from .node import short
293 from .node import short
294 RevlogError.__init__(self, '%s:%s' % (filename, short(node)))
294 StorageError.__init__(self, '%s:%s' % (filename, short(node)))
295 self.tombstone = tombstone
295 self.tombstone = tombstone
296
296
297 class CensoredBaseError(RevlogError):
297 class CensoredBaseError(StorageError):
298 """error raised when a delta is rejected because its base is censored
298 """error raised when a delta is rejected because its base is censored
299
299
300 A delta based on a censored revision must be formed as single patch
300 A delta based on a censored revision must be formed as single patch
@@ -435,7 +435,7 b' class hgweb(object):'
435 res.status = '404 Not Found'
435 res.status = '404 Not Found'
436 res.headers['Content-Type'] = ctype
436 res.headers['Content-Type'] = ctype
437 return rctx.sendtemplate('error', error=msg)
437 return rctx.sendtemplate('error', error=msg)
438 except (error.RepoError, error.RevlogError) as e:
438 except (error.RepoError, error.StorageError) as e:
439 res.status = '500 Internal Server Error'
439 res.status = '500 Internal Server Error'
440 res.headers['Content-Type'] = ctype
440 res.headers['Content-Type'] = ctype
441 return rctx.sendtemplate('error', error=pycompat.bytestr(e))
441 return rctx.sendtemplate('error', error=pycompat.bytestr(e))
@@ -643,7 +643,7 b' def _checkforbidden(l):'
643 """Check filenames for illegal characters."""
643 """Check filenames for illegal characters."""
644 for f in l:
644 for f in l:
645 if '\n' in f or '\r' in f:
645 if '\n' in f or '\r' in f:
646 raise error.RevlogError(
646 raise error.StorageError(
647 _("'\\n' and '\\r' disallowed in filenames: %r")
647 _("'\\n' and '\\r' disallowed in filenames: %r")
648 % pycompat.bytestr(f))
648 % pycompat.bytestr(f))
649
649
@@ -457,7 +457,8 b' def _textfromdelta(fh, revlog, baserev, '
457 if validatehash:
457 if validatehash:
458 revlog.checkhash(fulltext, expectednode, p1=p1, p2=p2)
458 revlog.checkhash(fulltext, expectednode, p1=p1, p2=p2)
459 if flags & REVIDX_ISCENSORED:
459 if flags & REVIDX_ISCENSORED:
460 raise error.RevlogError(_('node %s is not censored') % expectednode)
460 raise error.StorageError(_('node %s is not censored') %
461 expectednode)
461 except error.CensoredNodeError:
462 except error.CensoredNodeError:
462 # must pass the censored index flag to add censored revisions
463 # must pass the censored index flag to add censored revisions
463 if not flags & REVIDX_ISCENSORED:
464 if not flags & REVIDX_ISCENSORED:
@@ -207,7 +207,7 b' def callcatch(ui, func):'
207 ui.error("\n%r\n" % pycompat.bytestr(stringutil.ellipsis(msg)))
207 ui.error("\n%r\n" % pycompat.bytestr(stringutil.ellipsis(msg)))
208 except error.CensoredNodeError as inst:
208 except error.CensoredNodeError as inst:
209 ui.error(_("abort: file censored %s!\n") % inst)
209 ui.error(_("abort: file censored %s!\n") % inst)
210 except error.RevlogError as inst:
210 except error.StorageError as inst:
211 ui.error(_("abort: %s!\n") % inst)
211 ui.error(_("abort: %s!\n") % inst)
212 except error.InterventionRequired as inst:
212 except error.InterventionRequired as inst:
213 ui.error("%s\n" % inst)
213 ui.error("%s\n" % inst)
@@ -3448,7 +3448,7 b' class compressionengine(object):'
3448 The object has a ``decompress(data)`` method that decompresses
3448 The object has a ``decompress(data)`` method that decompresses
3449 data. The method will only be called if ``data`` begins with
3449 data. The method will only be called if ``data`` begins with
3450 ``revlogheader()``. The method should return the raw, uncompressed
3450 ``revlogheader()``. The method should return the raw, uncompressed
3451 data or raise a ``RevlogError``.
3451 data or raise a ``StorageError``.
3452
3452
3453 The object is reusable but is not thread safe.
3453 The object is reusable but is not thread safe.
3454 """
3454 """
@@ -3626,8 +3626,8 b' class _zlibengine(compressionengine):'
3626 try:
3626 try:
3627 return zlib.decompress(data)
3627 return zlib.decompress(data)
3628 except zlib.error as e:
3628 except zlib.error as e:
3629 raise error.RevlogError(_('revlog decompress error: %s') %
3629 raise error.StorageError(_('revlog decompress error: %s') %
3630 stringutil.forcebytestr(e))
3630 stringutil.forcebytestr(e))
3631
3631
3632 def revlogcompressor(self, opts=None):
3632 def revlogcompressor(self, opts=None):
3633 return self.zlibrevlogcompressor()
3633 return self.zlibrevlogcompressor()
@@ -3838,8 +3838,8 b' class _zstdengine(compressionengine):'
3838
3838
3839 return ''.join(chunks)
3839 return ''.join(chunks)
3840 except Exception as e:
3840 except Exception as e:
3841 raise error.RevlogError(_('revlog decompress error: %s') %
3841 raise error.StorageError(_('revlog decompress error: %s') %
3842 stringutil.forcebytestr(e))
3842 stringutil.forcebytestr(e))
3843
3843
3844 def revlogcompressor(self, opts=None):
3844 def revlogcompressor(self, opts=None):
3845 opts = opts or {}
3845 opts = opts or {}
@@ -360,7 +360,7 b' class verifier(object):'
360
360
361 try:
361 try:
362 fl = repo.file(f)
362 fl = repo.file(f)
363 except error.RevlogError as e:
363 except error.StorageError as e:
364 self.err(lr, _("broken revlog! (%s)") % e, f)
364 self.err(lr, _("broken revlog! (%s)") % e, f)
365 continue
365 continue
366
366
@@ -61,6 +61,9 b' 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):
@@ -261,8 +264,8 b' class filestorage(object):'
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
@@ -279,7 +282,7 b' class filestorage(object):'
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:
@@ -299,7 +302,7 b' class filestorage(object):'
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):
General Comments 0
You need to be logged in to leave comments. Login now