D6800: flagprocessors: introduce specialized functions
marmoute (Pierre-Yves David)
phabricator at mercurial-scm.org
Sat Sep 7 13:03:34 EDT 2019
Closed by commit rHG87a934684c3b: flagprocessors: introduce specialized functions (authored by marmoute).
This revision was automatically updated to reflect the committed changes.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D6800?vs=16405&id=16438
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D6800/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D6800
AFFECTED FILES
mercurial/revlogutils/flagutil.py
CHANGE DETAILS
diff --git a/mercurial/revlogutils/flagutil.py b/mercurial/revlogutils/flagutil.py
--- a/mercurial/revlogutils/flagutil.py
+++ b/mercurial/revlogutils/flagutil.py
@@ -90,12 +90,20 @@
_flagserrorclass = error.RevlogError
def _processflags(self, text, flags, operation, raw=False):
- """Inspect revision data flags and applies transforms defined by
- registered flag processors.
+ """deprecated entry point to access flag processors"""
+ if raw:
+ return text, self._processflagsraw(text, flags)
+ elif operation == 'read':
+ return self._processflagsread(text, flags)
+ else: # write operation
+ return self._processflagswrite(text, flags)
+
+ def _processflagsread(self, text, flags):
+ """Inspect revision data flags and applies read transformations defined
+ by registered flag processors.
``text`` - the revision data to process
``flags`` - the revision flags
- ``operation`` - the operation being performed (read or write)
``raw`` - an optional argument describing if the raw transform should be
applied.
@@ -107,10 +115,46 @@
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 self._processflagsfunc(text, flags, 'read')
- Note: If the ``raw`` argument is set, it has precedence over the
- operation and will only update the value of ``validatehash``.
+ def _processflagswrite(self, text, flags):
+ """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 self._processflagsfunc(text, flags, 'write')
+
+ 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 self._processflagsfunc(text, flags, 'read', raw=True)[1]
+
+ def _processflagsfunc(self, text, flags, operation, raw=False):
# fast path: no flag processors will run
if flags == 0:
return text, True
To: marmoute, yuja, durin42, #hg-reviewers, indygreg
Cc: indygreg, mercurial-devel
More information about the Mercurial-devel
mailing list