Patchwork [3,of,4,V2] flagutil: make the error class used by the mixin configurable

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 11, 2019, 11:10 a.m.
Message ID <6f91ac3cb36e88b6308b.1565521849@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/41244/
State New
Headers show

Comments

Pierre-Yves David - Aug. 11, 2019, 11:10 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1565219744 -7200
#      Thu Aug 08 01:15:44 2019 +0200
# Node ID 6f91ac3cb36e88b6308b8893c471c246f79deaf2
# Parent  3093392949b15d637ba09fb63670631bc3e9462c
# EXP-Topic flag-processors
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 6f91ac3cb36e
flagutil: make the error class used by the mixin configurable

One of the code duplication use a different error class. So let's make it
possible to do so.

Patch

diff --git a/mercurial/revlogutils/flagutil.py b/mercurial/revlogutils/flagutil.py
--- a/mercurial/revlogutils/flagutil.py
+++ b/mercurial/revlogutils/flagutil.py
@@ -87,6 +87,8 @@  class flagprocessorsmixin(object):
     See the documentation of the ``_processflags`` method for details.
     """
 
+    _flagserrorclass = error.RevlogError
+
     def _processflags(self, text, flags, operation, raw=False):
         """Inspect revision data flags and applies transforms defined by
         registered flag processors.
@@ -117,8 +119,8 @@  class flagprocessorsmixin(object):
                                          operation)
         # Check all flags are known.
         if flags & ~REVIDX_KNOWN_FLAGS:
-            raise error.RevlogError(_("incompatible revision flag '%#x'") %
-                                    (flags & ~REVIDX_KNOWN_FLAGS))
+            raise self._flagserrorclass(_("incompatible revision flag '%#x'") %
+                                        (flags & ~REVIDX_KNOWN_FLAGS))
         validatehash = True
         # Depending on the operation (read or write), the order might be
         # reversed due to non-commutative transforms.
@@ -134,7 +136,7 @@  class flagprocessorsmixin(object):
 
                 if flag not in self._flagprocessors:
                     message = _("missing processor for flag '%#x'") % (flag)
-                    raise error.RevlogError(message)
+                    raise self._flagserrorclass(message)
 
                 processor = self._flagprocessors[flag]
                 if processor is not None: