diff --git a/mercurial/error.py b/mercurial/error.py --- a/mercurial/error.py +++ b/mercurial/error.py @@ -34,7 +34,14 @@ class Hint(object): self.hint = kw.pop(r'hint', None) super(Hint, self).__init__(*args, **kw) -class RevlogError(Hint, Exception): +class StorageError(Hint, Exception): + """Raised when an error occurs in a storage layer. + + Usually subclassed by a storage-specific exception. + """ + __bytes__ = _tobytes + +class RevlogError(StorageError): __bytes__ = _tobytes class FilteredIndexError(IndexError): diff --git a/mercurial/repository.py b/mercurial/repository.py --- a/mercurial/repository.py +++ b/mercurial/repository.py @@ -571,7 +571,7 @@ class ifiledata(interfaceutil.Interface) def checkhash(fulltext, node, p1=None, p2=None, rev=None): """Validate the stored hash of a given fulltext and node. - Raises ``error.RevlogError`` is hash validation fails. + Raises ``error.StorageError`` is hash validation fails. """ def revision(node, raw=False): diff --git a/mercurial/testing/storage.py b/mercurial/testing/storage.py --- a/mercurial/testing/storage.py +++ b/mercurial/testing/storage.py @@ -422,7 +422,7 @@ class ifiledatatests(basetestcase): with self.assertRaises(IndexError): f.size(i) - with self.assertRaises(error.RevlogError): + with self.assertRaises(error.StorageError): f.checkhash(b'', nullid) with self.assertRaises(error.LookupError): @@ -527,13 +527,13 @@ class ifiledatatests(basetestcase): f.checkhash(fulltext, node) f.checkhash(fulltext, node, nullid, nullid) - with self.assertRaises(error.RevlogError): + with self.assertRaises(error.StorageError): f.checkhash(fulltext + b'extra', node) - with self.assertRaises(error.RevlogError): + with self.assertRaises(error.StorageError): f.checkhash(fulltext, node, b'\x01' * 20, nullid) - with self.assertRaises(error.RevlogError): + with self.assertRaises(error.StorageError): f.checkhash(fulltext, node, nullid, b'\x01' * 20) self.assertEqual(f.revision(node), fulltext) @@ -603,13 +603,13 @@ class ifiledatatests(basetestcase): f.checkhash(fulltext1, node1, node0, nullid) f.checkhash(fulltext2, node2, node1, nullid) - with self.assertRaises(error.RevlogError): + with self.assertRaises(error.StorageError): f.checkhash(fulltext1, b'\x01' * 20) - with self.assertRaises(error.RevlogError): + with self.assertRaises(error.StorageError): f.checkhash(fulltext1 + b'extra', node1, node0, nullid) - with self.assertRaises(error.RevlogError): + with self.assertRaises(error.StorageError): f.checkhash(fulltext1, node1, node0, node0) self.assertEqual(f.revision(node0), fulltext0) @@ -852,7 +852,7 @@ class ifilemutationtests(basetestcase): f = self._makefilefn() with self._maketransactionfn() as tr: # Adding a revision with bad node value fails. - with self.assertRaises(error.RevlogError): + with self.assertRaises(error.StorageError): f.addrevision(b'foo', tr, 0, nullid, nullid, node=b'\x01' * 20) def testaddrevisionunknownflag(self): @@ -863,7 +863,7 @@ class ifilemutationtests(basetestcase): flags = 1 << i break - with self.assertRaises(error.RevlogError): + with self.assertRaises(error.StorageError): f.addrevision(b'foo', tr, 0, nullid, nullid, flags=flags) def testaddgroupsimple(self): @@ -891,7 +891,7 @@ class ifilemutationtests(basetestcase): ] with self._maketransactionfn() as tr: - with self.assertRaises(error.RevlogError): + with self.assertRaises(error.StorageError): f.addgroup(deltas, linkmapper, tr, addrevisioncb=cb) node0 = f.add(fulltext0, None, tr, 0, nullid, nullid)