flagprocessors: make `processflagsraw` a module level function
One more steps toward removing the mixin.
Differential Revision: https://phab.mercurial-scm.org/D6820
--- a/mercurial/revlog.py Sat Sep 07 00:11:58 2019 +0200
+++ b/mercurial/revlog.py Sat Sep 07 00:16:32 2019 +0200
@@ -1660,7 +1660,7 @@
sidedata = {}
if raw:
- validatehash = self._processflagsraw(rawtext, flags)
+ validatehash = flagutil.processflagsraw(self, rawtext, flags)
text = rawtext
else:
r = flagutil.processflagsread(self, rawtext, flags)
--- a/mercurial/revlogutils/deltas.py Sat Sep 07 00:11:58 2019 +0200
+++ b/mercurial/revlogutils/deltas.py Sat Sep 07 00:16:32 2019 +0200
@@ -33,6 +33,10 @@
util,
)
+from . import (
+ flagutil,
+)
+
# maximum <delta-chain-data>/<revision-text-length> ratio
LIMIT_DELTA2TEXT = 2
@@ -521,7 +525,7 @@
fulltext = mdiff.patch(basetext, delta)
try:
- validatehash = revlog._processflagsraw(fulltext, flags)
+ validatehash = flagutil.processflagsraw(revlog, fulltext, flags)
if validatehash:
revlog.checkhash(fulltext, expectednode, p1=p1, p2=p2)
if flags & REVIDX_ISCENSORED:
--- a/mercurial/revlogutils/flagutil.py Sat Sep 07 00:11:58 2019 +0200
+++ b/mercurial/revlogutils/flagutil.py Sat Sep 07 00:16:32 2019 +0200
@@ -94,30 +94,12 @@
msg = ('_processflag(...) use the specialized variant')
util.nouideprecwarn(msg, '5.2', stacklevel=2)
if raw:
- return text, self._processflagsraw(text, flags)
+ return text, processflagsraw(self, text, flags)
elif operation == 'read':
return processflagsread(self, text, flags)
else: # write operation
return processflagswrite(self, text, flags)
- def _processflagsraw(self, text, flags):
- """Inspect revision data flags to check is the content hash should be
- validated.
-
- ``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, 'raw')[1]
-
def processflagswrite(revlog, text, flags, sidedata):
"""Inspect revision data flags and applies write transformations defined
by registered flag processors.
@@ -157,6 +139,24 @@
"""
return _processflagsfunc(revlog, text, flags, 'read')
+def processflagsraw(revlog, text, flags):
+ """Inspect revision data flags to check is the content hash should be
+ validated.
+
+ ``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, 'raw')[1]
+
def _processflagsfunc(revlog, text, flags, operation, sidedata=None):
"""internal function to process flag on a revlog
--- a/tests/simplestorerepo.py Sat Sep 07 00:11:58 2019 +0200
+++ b/tests/simplestorerepo.py Sat Sep 07 00:16:32 2019 +0200
@@ -291,7 +291,7 @@
rawtext = self._svfs.read(path)
if raw:
- validatehash = self._processflagsraw(rawtext, flags)
+ validatehash = flagutil.processflagsraw(self, rawtext, flags)
text = rawtext
else:
r = flagutil.processflagsread(self, rawtext, flags)