Patchwork [2,of,9] flagutil: move the `flagprocessors` mapping in the new module

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 8, 2019, 1:47 a.m.
Message ID <6e9396b0817a0e161ff3.1565228838@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/41214/
State Accepted
Headers show

Comments

Pierre-Yves David - Aug. 8, 2019, 1:47 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1565219088 -7200
#      Thu Aug 08 01:04:48 2019 +0200
# Node ID 6e9396b0817a0e161ff340eab6aeb9c220b1d4df
# Parent  536a1081efbe3cf9ae150af69ab10c6152e8197d
# EXP-Topic flag-processors
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 6e9396b0817a
flagutil: move the `flagprocessors` mapping in the new module

This module is meant to host most of the flag processing logic. We start with
the mapping between flag and processors.

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -72,6 +72,7 @@  from . import (
 )
 from .revlogutils import (
     deltas as deltautil,
+    flagutil,
 )
 from .utils import (
     interfaceutil,
@@ -110,11 +111,6 @@  rustdagop = policy.importrust(r'dagop')
 _maxinline = 131072
 _chunksize = 1048576
 
-# Store flag processors (cf. 'addflagprocessor()' to register)
-_flagprocessors = {
-    REVIDX_ISCENSORED: None,
-}
-
 # Flag processors for REVIDX_ELLIPSIS.
 def ellipsisreadprocessor(rl, text):
     return text, False
@@ -156,7 +152,7 @@  def addflagprocessor(flag, processor):
       debug commands. In this case the transform only indicates whether the
       contents can be used for hash integrity checks.
     """
-    _insertflagprocessor(flag, processor, _flagprocessors)
+    _insertflagprocessor(flag, processor, flagutil.flagprocessors)
 
 def _insertflagprocessor(flag, processor, flagprocessors):
     if not flag & REVIDX_KNOWN_FLAGS:
@@ -386,7 +382,7 @@  class revlog(object):
 
         # Make copy of flag processors so each revlog instance can support
         # custom flags.
-        self._flagprocessors = dict(_flagprocessors)
+        self._flagprocessors = dict(flagutil.flagprocessors)
 
         # 2-tuple of file handles being used for active writing.
         self._writinghandles = None
diff --git a/mercurial/revlogutils/flagutil.py b/mercurial/revlogutils/flagutil.py
--- a/mercurial/revlogutils/flagutil.py
+++ b/mercurial/revlogutils/flagutil.py
@@ -28,4 +28,8 @@  REVIDX_FLAGS_ORDER
 REVIDX_KNOWN_FLAGS
 REVIDX_RAWTEXT_CHANGING_FLAGS
 
+# Store flag processors (cf. 'addflagprocessor()' to register)
+flagprocessors = {
+    REVIDX_ISCENSORED: None,
+}
 
diff --git a/tests/test-flagprocessor.t b/tests/test-flagprocessor.t
--- a/tests/test-flagprocessor.t
+++ b/tests/test-flagprocessor.t
@@ -206,7 +206,7 @@  Ensure the data got to the server OK
     File "*/tests/flagprocessorext.py", line *, in extsetup (glob)
       validatehash,
     File "*/mercurial/revlog.py", line *, in addflagprocessor (glob)
-      _insertflagprocessor(flag, processor, _flagprocessors)
+      _insertflagprocessor(flag, processor, flagutil.flagprocessors)
     File "*/mercurial/revlog.py", line *, in _insertflagprocessor (glob)
       raise error.Abort(msg)
   mercurial.error.Abort: b"cannot register multiple processors on flag '0x8'." (py3 !)