Patchwork D6807: flagprocessors: small code update to clarify parameters

login
register
mail settings
Submitter phabricator
Date Sept. 7, 2019, 9:27 a.m.
Message ID <differential-rev-PHID-DREV-vnvi7nwqymhilfypf3tz-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/41512/
State Superseded
Headers show

Comments

phabricator - Sept. 7, 2019, 9:27 a.m.
marmoute created this revision.
marmoute added reviewers: yuja, durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  'raw' is really a third mode, not a small variant.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6807

AFFECTED FILES
  mercurial/revlogutils/flagutil.py

CHANGE DETAILS




To: marmoute, yuja, durin42, #hg-reviewers
Cc: mercurial-devel
phabricator - Sept. 7, 2019, 5:08 p.m.
This revision is now accepted and ready to land.
indygreg added inline comments.
indygreg accepted this revision.

INLINE COMMENTS

> flagutil.py:163
>              return text, True
> -        if not operation in ('read', 'write'):
> +        if not operation in ('read', 'write', 'raw'):
>              raise error.ProgrammingError(_("invalid '%s' operation") %

I'm going to change this to use `not in` in flight.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6807/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D6807

To: marmoute, yuja, durin42, #hg-reviewers, indygreg
Cc: indygreg, mercurial-devel

Patch

diff --git a/mercurial/revlogutils/flagutil.py b/mercurial/revlogutils/flagutil.py
--- a/mercurial/revlogutils/flagutil.py
+++ b/mercurial/revlogutils/flagutil.py
@@ -154,13 +154,13 @@ 
         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]
+        return self._processflagsfunc(text, flags, 'raw')[1]
 
-    def _processflagsfunc(self, text, flags, operation, raw=False):
+    def _processflagsfunc(self, text, flags, operation):
         # fast path: no flag processors will run
         if flags == 0:
             return text, True
-        if not operation in ('read', 'write'):
+        if not operation in ('read', 'write', 'raw'):
             raise error.ProgrammingError(_("invalid '%s' operation") %
                                          operation)
         # Check all flags are known.
@@ -188,7 +188,7 @@ 
                 if processor is not None:
                     readtransform, writetransform, rawtransform = processor
 
-                    if raw:
+                    if operation == 'raw':
                         vhash = rawtransform(self, text)
                     elif operation == 'read':
                         text, vhash = readtransform(self, text)