Mercurial > public > mercurial-scm > hg
diff 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 |
line wrap: on
line diff
--- a/tests/simplestorerepo.py Tue Sep 18 16:45:13 2018 -0700 +++ b/tests/simplestorerepo.py Tue Sep 18 16:47:09 2018 -0700 @@ -61,6 +61,9 @@ if not isinstance(rev, int): raise ValueError('expected int') +class simplestoreerror(error.StorageError): + pass + @interfaceutil.implementer(repository.irevisiondelta) @attr.s(slots=True, frozen=True) class simplestorerevisiondelta(object): @@ -261,8 +264,8 @@ return text, True if flags & ~revlog.REVIDX_KNOWN_FLAGS: - raise error.RevlogError(_("incompatible revision flag '%#x'") % - (flags & ~revlog.REVIDX_KNOWN_FLAGS)) + raise simplestoreerror(_("incompatible revision flag '%#x'") % + (flags & ~revlog.REVIDX_KNOWN_FLAGS)) validatehash = True # Depending on the operation (read or write), the order might be @@ -279,7 +282,7 @@ if flag not in revlog._flagprocessors: message = _("missing processor for flag '%#x'") % (flag) - raise error.RevlogError(message) + raise simplestoreerror(message) processor = revlog._flagprocessors[flag] if processor is not None: @@ -299,7 +302,7 @@ if p1 is None and p2 is None: p1, p2 = self.parents(node) if node != revlog.hash(text, p1, p2): - raise error.RevlogError(_("integrity check failed on %s") % + raise simplestoreerror(_("integrity check failed on %s") % self._path) def revision(self, node, raw=False):