Patchwork D6798: flagutil: make the error class used by the mixin configurable

login
register
mail settings
Submitter phabricator
Date Sept. 7, 2019, 9:26 a.m.
Message ID <differential-rev-PHID-DREV-mifxmyewt4c4eefiu5m4-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/41502/
State Superseded
Headers show

Comments

phabricator - Sept. 7, 2019, 9:26 a.m.
marmoute created this revision.
marmoute added reviewers: yuja, durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

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

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/revlogutils/flagutil.py

CHANGE DETAILS




To: marmoute, yuja, durin42, #hg-reviewers
Cc: mercurial-devel

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 @@ 
     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 @@ 
                                          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 @@ 
 
                 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: