diff mercurial/revlog.py @ 42731:5109217a9ab6

flagutil: move insertflagprocessor to the new module (API)
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 08 Aug 2019 01:25:37 +0200
parents 92ac6b1697a7
children 6d61be152c55
line wrap: on
line diff
--- a/mercurial/revlog.py	Thu Aug 08 01:28:34 2019 +0200
+++ b/mercurial/revlog.py	Thu Aug 08 01:25:37 2019 +0200
@@ -150,19 +150,7 @@
       debug commands. In this case the transform only indicates whether the
       contents can be used for hash integrity checks.
     """
-    _insertflagprocessor(flag, processor, flagutil.flagprocessors)
-
-def _insertflagprocessor(flag, processor, flagprocessors):
-    if not flag & flagutil.REVIDX_KNOWN_FLAGS:
-        msg = _("cannot register processor on unknown flag '%#x'.") % (flag)
-        raise error.ProgrammingError(msg)
-    if flag not in REVIDX_FLAGS_ORDER:
-        msg = _("flag '%#x' undefined in REVIDX_FLAGS_ORDER.") % (flag)
-        raise error.ProgrammingError(msg)
-    if flag in flagprocessors:
-        msg = _("cannot register multiple processors on flag '%#x'.") % (flag)
-        raise error.Abort(msg)
-    flagprocessors[flag] = processor
+    flagutil.insertflagprocessor(flag, processor, flagutil.flagprocessors)
 
 def getoffset(q):
     return int(q >> 16)
@@ -438,7 +426,7 @@
 
         # revlog v0 doesn't have flag processors
         for flag, processor in opts.get(b'flagprocessors', {}).iteritems():
-            _insertflagprocessor(flag, processor, self._flagprocessors)
+            flagutil.insertflagprocessor(flag, processor, self._flagprocessors)
 
         if self._chunkcachesize <= 0:
             raise error.RevlogError(_('revlog chunk cache size %r is not '