D4655: global: replace most uses of RevlogError with StorageError (API)

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


This revision was automatically updated to reflect the committed changes.
Closed by commit rHGb63dee7bd0d9: global: replace most uses of RevlogError with StorageError (API) (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4655?vs=11189&id=11281

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

AFFECTED FILES
  hgext/lfs/blobstore.py
  hgext/lfs/pointer.py
  hgext/transplant.py
  mercurial/changelog.py
  mercurial/error.py
  mercurial/hgweb/hgweb_mod.py
  mercurial/manifest.py
  mercurial/revlogutils/deltas.py
  mercurial/scmutil.py
  mercurial/util.py
  mercurial/verify.py
  tests/simplestorerepo.py

CHANGE DETAILS

diff --git a/tests/simplestorerepo.py b/tests/simplestorerepo.py
--- a/tests/simplestorerepo.py
+++ b/tests/simplestorerepo.py
@@ -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):
diff --git a/mercurial/verify.py b/mercurial/verify.py
--- a/mercurial/verify.py
+++ b/mercurial/verify.py
@@ -360,7 +360,7 @@
 
             try:
                 fl = repo.file(f)
-            except error.RevlogError as e:
+            except error.StorageError as e:
                 self.err(lr, _("broken revlog! (%s)") % e, f)
                 continue
 
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -3448,7 +3448,7 @@
         The object has a ``decompress(data)`` method that decompresses
         data. The method will only be called if ``data`` begins with
         ``revlogheader()``. The method should return the raw, uncompressed
-        data or raise a ``RevlogError``.
+        data or raise a ``StorageError``.
 
         The object is reusable but is not thread safe.
         """
@@ -3626,8 +3626,8 @@
             try:
                 return zlib.decompress(data)
             except zlib.error as e:
-                raise error.RevlogError(_('revlog decompress error: %s') %
-                                        stringutil.forcebytestr(e))
+                raise error.StorageError(_('revlog decompress error: %s') %
+                                         stringutil.forcebytestr(e))
 
     def revlogcompressor(self, opts=None):
         return self.zlibrevlogcompressor()
@@ -3838,8 +3838,8 @@
 
                 return ''.join(chunks)
             except Exception as e:
-                raise error.RevlogError(_('revlog decompress error: %s') %
-                                        stringutil.forcebytestr(e))
+                raise error.StorageError(_('revlog decompress error: %s') %
+                                         stringutil.forcebytestr(e))
 
     def revlogcompressor(self, opts=None):
         opts = opts or {}
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -207,7 +207,7 @@
             ui.error("\n%r\n" % pycompat.bytestr(stringutil.ellipsis(msg)))
     except error.CensoredNodeError as inst:
         ui.error(_("abort: file censored %s!\n") % inst)
-    except error.RevlogError as inst:
+    except error.StorageError as inst:
         ui.error(_("abort: %s!\n") % inst)
     except error.InterventionRequired as inst:
         ui.error("%s\n" % inst)
diff --git a/mercurial/revlogutils/deltas.py b/mercurial/revlogutils/deltas.py
--- a/mercurial/revlogutils/deltas.py
+++ b/mercurial/revlogutils/deltas.py
@@ -457,7 +457,8 @@
         if validatehash:
             revlog.checkhash(fulltext, expectednode, p1=p1, p2=p2)
         if flags & REVIDX_ISCENSORED:
-            raise error.RevlogError(_('node %s is not censored') % expectednode)
+            raise error.StorageError(_('node %s is not censored') %
+                                     expectednode)
     except error.CensoredNodeError:
         # must pass the censored index flag to add censored revisions
         if not flags & REVIDX_ISCENSORED:
diff --git a/mercurial/manifest.py b/mercurial/manifest.py
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -643,7 +643,7 @@
     """Check filenames for illegal characters."""
     for f in l:
         if '\n' in f or '\r' in f:
-            raise error.RevlogError(
+            raise error.StorageError(
                 _("'\\n' and '\\r' disallowed in filenames: %r")
                 % pycompat.bytestr(f))
 
diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py
+++ b/mercurial/hgweb/hgweb_mod.py
@@ -435,7 +435,7 @@
             res.status = '404 Not Found'
             res.headers['Content-Type'] = ctype
             return rctx.sendtemplate('error', error=msg)
-        except (error.RepoError, error.RevlogError) as e:
+        except (error.RepoError, error.StorageError) as e:
             res.status = '500 Internal Server Error'
             res.headers['Content-Type'] = ctype
             return rctx.sendtemplate('error', error=pycompat.bytestr(e))
diff --git a/mercurial/error.py b/mercurial/error.py
--- a/mercurial/error.py
+++ b/mercurial/error.py
@@ -283,18 +283,18 @@
         Abort.__init__(self, 'failed to update value for "%s/%s"'
                        % (namespace, key))
 
-class CensoredNodeError(RevlogError):
+class CensoredNodeError(StorageError):
     """error raised when content verification fails on a censored node
 
     Also contains the tombstone data substituted for the uncensored data.
     """
 
     def __init__(self, filename, node, tombstone):
         from .node import short
-        RevlogError.__init__(self, '%s:%s' % (filename, short(node)))
+        StorageError.__init__(self, '%s:%s' % (filename, short(node)))
         self.tombstone = tombstone
 
-class CensoredBaseError(RevlogError):
+class CensoredBaseError(StorageError):
     """error raised when a delta is rejected because its base is censored
 
     A delta based on a censored revision must be formed as single patch
diff --git a/mercurial/changelog.py b/mercurial/changelog.py
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -513,10 +513,10 @@
         # revision text contain two "\n\n" sequences -> corrupt
         # repository since read cannot unpack the revision.
         if not user:
-            raise error.RevlogError(_("empty username"))
+            raise error.StorageError(_("empty username"))
         if "\n" in user:
-            raise error.RevlogError(_("username %r contains a newline")
-                                    % pycompat.bytestr(user))
+            raise error.StorageError(_("username %r contains a newline")
+                                     % pycompat.bytestr(user))
 
         desc = stripdesc(desc)
 
@@ -529,8 +529,8 @@
             if branch in ("default", ""):
                 del extra["branch"]
             elif branch in (".", "null", "tip"):
-                raise error.RevlogError(_('the name \'%s\' is reserved')
-                                        % branch)
+                raise error.StorageError(_('the name \'%s\' is reserved')
+                                         % branch)
         if extra:
             extra = encodeextra(extra)
             parseddate = "%s %s" % (parseddate, extra)
diff --git a/hgext/transplant.py b/hgext/transplant.py
--- a/hgext/transplant.py
+++ b/hgext/transplant.py
@@ -503,7 +503,7 @@
 def hasnode(repo, node):
     try:
         return repo.changelog.rev(node) is not None
-    except error.RevlogError:
+    except error.StorageError:
         return False
 
 def browserevs(ui, repo, nodes, opts):
diff --git a/hgext/lfs/pointer.py b/hgext/lfs/pointer.py
--- a/hgext/lfs/pointer.py
+++ b/hgext/lfs/pointer.py
@@ -19,7 +19,7 @@
     stringutil,
 )
 
-class InvalidPointer(error.RevlogError):
+class InvalidPointer(error.StorageError):
     pass
 
 class gitlfspointer(dict):
diff --git a/hgext/lfs/blobstore.py b/hgext/lfs/blobstore.py
--- a/hgext/lfs/blobstore.py
+++ b/hgext/lfs/blobstore.py
@@ -586,7 +586,7 @@
         raise error.Abort(_('lfs: unknown url scheme: %s') % scheme)
     return _storemap[scheme](repo, url)
 
-class LfsRemoteError(error.RevlogError):
+class LfsRemoteError(error.StorageError):
     pass
 
 class LfsCorruptionError(error.Abort):



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


More information about the Mercurial-devel mailing list