mercurial/revlog.py
changeset 40267 9d5ddf55415b
parent 40180 ba70e3acf58a
child 40298 9cadb0f5f227
--- a/mercurial/revlog.py	Fri Oct 12 17:34:45 2018 -0400
+++ b/mercurial/revlog.py	Tue Oct 09 21:53:21 2018 -0400
@@ -151,16 +151,19 @@
       debug commands. In this case the transform only indicates whether the
       contents can be used for hash integrity checks.
     """
+    _insertflagprocessor(flag, processor, _flagprocessors)
+
+def _insertflagprocessor(flag, processor, flagprocessors):
     if not flag & 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:
+    if flag in flagprocessors:
         msg = _("cannot register multiple processors on flag '%#x'.") % (flag)
         raise error.Abort(msg)
-    _flagprocessors[flag] = processor
+    flagprocessors[flag] = processor
 
 def getoffset(q):
     return int(q >> 16)
@@ -408,6 +411,10 @@
             if opts.get('enableellipsis'):
                 self._flagprocessors[REVIDX_ELLIPSIS] = ellipsisprocessor
 
+            # revlog v0 doesn't have flag processors
+            for flag, processor in opts.get(b'flagprocessors', {}).iteritems():
+                _insertflagprocessor(flag, processor, self._flagprocessors)
+
         if self._chunkcachesize <= 0:
             raise error.RevlogError(_('revlog chunk cache size %r is not '
                                       'greater than 0') % self._chunkcachesize)