D4654: error: introduce StorageError

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Sun Sep 23 06:13:16 EDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rHGcb65d4b7e429: error: introduce StorageError (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4654?vs=11188&id=11280

REVISION DETAIL
  https://phab.mercurial-scm.org/D4654

AFFECTED FILES
  mercurial/error.py
  mercurial/repository.py
  mercurial/testing/storage.py

CHANGE DETAILS

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 @@
             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 @@
         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 @@
         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 @@
         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 @@
                     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 @@
         ]
 
         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)
diff --git a/mercurial/repository.py b/mercurial/repository.py
--- a/mercurial/repository.py
+++ b/mercurial/repository.py
@@ -571,7 +571,7 @@
     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/error.py b/mercurial/error.py
--- a/mercurial/error.py
+++ b/mercurial/error.py
@@ -34,7 +34,14 @@
         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):



To: indygreg, #hg-reviewers
Cc: yuja, mercurial-devel


More information about the Mercurial-devel mailing list