diff mercurial/revlogutils/flagutil.py @ 42990:a04b2c010d03

flagprocessors: make `processflagswrite` a module level function One more step towards removing the mixin. Differential Revision: https://phab.mercurial-scm.org/D6818
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 06 Sep 2019 23:50:32 +0200
parents 50d9de61ce02
children eb5048f8c533
line wrap: on
line diff
--- a/mercurial/revlogutils/flagutil.py	Fri Sep 06 23:43:06 2019 +0200
+++ b/mercurial/revlogutils/flagutil.py	Fri Sep 06 23:50:32 2019 +0200
@@ -98,7 +98,7 @@
         elif operation == 'read':
             return self._processflagsread(text, flags)
         else: # write operation
-            return self._processflagswrite(text, flags)
+            return processflagswrite(self, text, flags)
 
     def _processflagsread(self, text, flags):
         """Inspect revision data flags and applies read transformations defined
@@ -120,25 +120,6 @@
         """
         return _processflagsfunc(self, text, flags, 'read')
 
-    def _processflagswrite(self, text, flags, sidedata):
-        """Inspect revision data flags and applies write transformations defined
-        by registered flag processors.
-
-        ``text`` - the revision data to process
-        ``flags`` - the revision flags
-
-        This method processes the flags in the order (or reverse order if
-        ``operation`` is 'write') defined by REVIDX_FLAGS_ORDER, applying the
-        flag processors registered for present flags. The order of flags defined
-        in REVIDX_FLAGS_ORDER needs to be stable to allow non-commutativity.
-
-        Returns a 2-tuple of ``(text, validatehash)`` where ``text`` is the
-        processed text and ``validatehash`` is a bool indicating whether the
-        returned text should be checked for hash integrity.
-        """
-        return _processflagsfunc(self, text, flags, 'write',
-                                 sidedata=sidedata)[:2]
-
     def _processflagsraw(self, text, flags):
         """Inspect revision data flags to check is the content hash should be
         validated.
@@ -157,6 +138,25 @@
         """
         return _processflagsfunc(self, text, flags, 'raw')[1]
 
+def processflagswrite(revlog, text, flags, sidedata):
+    """Inspect revision data flags and applies write transformations defined
+    by registered flag processors.
+
+    ``text`` - the revision data to process
+    ``flags`` - the revision flags
+
+    This method processes the flags in the order (or reverse order if
+    ``operation`` is 'write') defined by REVIDX_FLAGS_ORDER, applying the
+    flag processors registered for present flags. The order of flags defined
+    in REVIDX_FLAGS_ORDER needs to be stable to allow non-commutativity.
+
+    Returns a 2-tuple of ``(text, validatehash)`` where ``text`` is the
+    processed text and ``validatehash`` is a bool indicating whether the
+    returned text should be checked for hash integrity.
+    """
+    return _processflagsfunc(revlog, text, flags, 'write',
+                             sidedata=sidedata)[:2]
+
 def _processflagsfunc(revlog, text, flags, operation, sidedata=None):
     """internal function to process flag on a revlog