Patchwork D6816: flagprocessors: writetransform function take side data as parameter (API)

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

Comments

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

REVISION SUMMARY
  If we want some flag processors to be able to store sidedata it needs to be
  actually fed that data.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/lfs/wrapper.py
  mercurial/revlog.py
  mercurial/revlogutils/flagutil.py
  tests/flagprocessorext.py
  tests/test-revlog-raw.py

CHANGE DETAILS




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

Patch

diff --git a/tests/test-revlog-raw.py b/tests/test-revlog-raw.py
--- a/tests/test-revlog-raw.py
+++ b/tests/test-revlog-raw.py
@@ -47,7 +47,7 @@ 
     text = rawtext[len(_extheader):].replace(b'i', b'1')
     return text, True, {}
 
-def writeprocessor(self, text):
+def writeprocessor(self, text, sidedata):
     # False: the returned rawtext shouldn't be used to verify hash
     rawtext = _extheader + text.replace(b'1', b'i')
     return rawtext, False
@@ -262,7 +262,7 @@ 
 
         # Verify text, rawtext, and rawsize
         if isext:
-            rawtext = writeprocessor(None, text)[0]
+            rawtext = writeprocessor(None, text, {})[0]
         else:
             rawtext = text
         if rlog.rawsize(rev) != len(rawtext):
diff --git a/tests/flagprocessorext.py b/tests/flagprocessorext.py
--- a/tests/flagprocessorext.py
+++ b/tests/flagprocessorext.py
@@ -30,19 +30,19 @@ 
 def bypass(self, text):
     return False
 
-def noopdonothing(self, text):
+def noopdonothing(self, text, sidedata):
     return (text, True)
 
 def noopdonothingread(self, text):
     return (text, True, {})
 
-def b64encode(self, text):
+def b64encode(self, text, sidedata):
     return (base64.b64encode(text), False)
 
 def b64decode(self, text):
     return (base64.b64decode(text), True, {})
 
-def gzipcompress(self, text):
+def gzipcompress(self, text, sidedata):
     return (zlib.compress(text), False)
 
 def gzipdecompress(self, text):
diff --git a/mercurial/revlogutils/flagutil.py b/mercurial/revlogutils/flagutil.py
--- a/mercurial/revlogutils/flagutil.py
+++ b/mercurial/revlogutils/flagutil.py
@@ -136,8 +136,8 @@ 
         processed text and ``validatehash`` is a bool indicating whether the
         returned text should be checked for hash integrity.
         """
-        assert not sidedata # XXX until it is actually processed
-        return self._processflagsfunc(text, flags, 'write')[:2]
+        return self._processflagsfunc(text, flags, 'write',
+                                      sidedata=sidedata)[:2]
 
     def _processflagsraw(self, text, flags):
         """Inspect revision data flags to check is the content hash should be
@@ -157,7 +157,7 @@ 
         """
         return self._processflagsfunc(text, flags, 'raw')[1]
 
-    def _processflagsfunc(self, text, flags, operation):
+    def _processflagsfunc(self, text, flags, operation, sidedata=None):
         # fast path: no flag processors will run
         if flags == 0:
             return text, True, {}
@@ -196,7 +196,7 @@ 
                         text, vhash, s = readtransform(self, text)
                         sidedata.update(s)
                     else: # write operation
-                        text, vhash = writetransform(self, text)
+                        text, vhash = writetransform(self, text, sidedata)
                 validatehash = validatehash and vhash
 
         return text, validatehash, sidedata
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -115,7 +115,7 @@ 
 def ellipsisreadprocessor(rl, text):
     return text, False, {}
 
-def ellipsiswriteprocessor(rl, text):
+def ellipsiswriteprocessor(rl, text, sidedata):
     return text, False
 
 def ellipsisrawprocessor(rl, text):
diff --git a/hgext/lfs/wrapper.py b/hgext/lfs/wrapper.py
--- a/hgext/lfs/wrapper.py
+++ b/hgext/lfs/wrapper.py
@@ -106,7 +106,7 @@ 
 
     return (text, True, {})
 
-def writetostore(self, text):
+def writetostore(self, text, sidedata):
     # hg filelog metadata (includes rename, etc)
     hgmeta, offset = storageutil.parsemeta(text)
     if offset and offset > 0: