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

marmoute (Pierre-Yves David) phabricator at mercurial-scm.org
Mon Sep 9 19:10:54 EDT 2019


marmoute updated this revision to Diff 16496.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6816?vs=16482&id=16496

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

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

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)
                         outsidedata.update(s)
                     else: # write operation
-                        text, vhash = writetransform(self, text)
+                        text, vhash = writetransform(self, text, sidedata)
                 validatehash = validatehash and vhash
 
         return text, validatehash, outsidedata
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:



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


More information about the Mercurial-devel mailing list