From patchwork Thu Aug 8 01:47:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [8, of, 9] flagutil: make the error class used by the mixin configurable From: Pierre-Yves David X-Patchwork-Id: 41217 Message-Id: <9ee2ada7f37ba4278740.1565228844@nodosa.octopoid.net> To: mercurial-devel@mercurial-scm.org Date: Thu, 08 Aug 2019 03:47:24 +0200 # HG changeset patch # User Pierre-Yves David # Date 1565219744 -7200 # Thu Aug 08 01:15:44 2019 +0200 # Node ID 9ee2ada7f37ba42787408c03074206cf0bb828de # Parent 2e87598264f883b252a39664f2e2618e9de13e42 # EXP-Topic flag-processors # Available At https://bitbucket.org/octobus/mercurial-devel/ # hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 9ee2ada7f37b 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. diff --git a/mercurial/revlogutils/flagutil.py b/mercurial/revlogutils/flagutil.py --- a/mercurial/revlogutils/flagutil.py +++ b/mercurial/revlogutils/flagutil.py @@ -103,6 +103,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. @@ -133,8 +135,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. @@ -150,7 +152,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: