changeset 42985:bd5858c28bbe

flagprocessors: have the read transform function return side data (API) This makes it possible for flag processors to -read- flag data. Differential Revision: https://phab.mercurial-scm.org/D6813
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 04 Sep 2019 00:34:03 +0200
parents 66dc5a522f37
children 33532939c667
files hgext/lfs/wrapper.py mercurial/revlog.py mercurial/revlogutils/flagutil.py tests/flagprocessorext.py tests/test-revlog-raw.py
diffstat 5 files changed, 11 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/lfs/wrapper.py	Wed Sep 04 00:13:45 2019 +0200
+++ b/hgext/lfs/wrapper.py	Wed Sep 04 00:34:03 2019 +0200
@@ -104,7 +104,7 @@
     if hgmeta or text.startswith('\1\n'):
         text = storageutil.packmeta(hgmeta, text)
 
-    return (text, True)
+    return (text, True, {})
 
 def writetostore(self, text):
     # hg filelog metadata (includes rename, etc)
--- a/mercurial/revlog.py	Wed Sep 04 00:13:45 2019 +0200
+++ b/mercurial/revlog.py	Wed Sep 04 00:34:03 2019 +0200
@@ -113,7 +113,7 @@
 
 # Flag processors for REVIDX_ELLIPSIS.
 def ellipsisreadprocessor(rl, text):
-    return text, False
+    return text, False, {}
 
 def ellipsiswriteprocessor(rl, text):
     return text, False
--- a/mercurial/revlogutils/flagutil.py	Wed Sep 04 00:13:45 2019 +0200
+++ b/mercurial/revlogutils/flagutil.py	Wed Sep 04 00:34:03 2019 +0200
@@ -192,7 +192,8 @@
                     if operation == 'raw':
                         vhash = rawtransform(self, text)
                     elif operation == 'read':
-                        text, vhash = readtransform(self, text)
+                        text, vhash, s = readtransform(self, text)
+                        outsidedata.update(s)
                     else: # write operation
                         text, vhash = writetransform(self, text)
                 validatehash = validatehash and vhash
--- a/tests/flagprocessorext.py	Wed Sep 04 00:13:45 2019 +0200
+++ b/tests/flagprocessorext.py	Wed Sep 04 00:34:03 2019 +0200
@@ -33,17 +33,20 @@
 def noopdonothing(self, text):
     return (text, True)
 
+def noopdonothingread(self, text):
+    return (text, True, {})
+
 def b64encode(self, text):
     return (base64.b64encode(text), False)
 
 def b64decode(self, text):
-    return (base64.b64decode(text), True)
+    return (base64.b64decode(text), True, {})
 
 def gzipcompress(self, text):
     return (zlib.compress(text), False)
 
 def gzipdecompress(self, text):
-    return (zlib.decompress(text), True)
+    return (zlib.decompress(text), True, {})
 
 def supportedoutgoingversions(orig, repo):
     versions = orig(repo)
@@ -116,7 +119,7 @@
     flagutil.addflagprocessor(
         REVIDX_NOOP,
         (
-            noopdonothing,
+            noopdonothingread,
             noopdonothing,
             validatehash,
         )
--- a/tests/test-revlog-raw.py	Wed Sep 04 00:13:45 2019 +0200
+++ b/tests/test-revlog-raw.py	Wed Sep 04 00:34:03 2019 +0200
@@ -45,7 +45,7 @@
 def readprocessor(self, rawtext):
     # True: the returned text could be used to verify hash
     text = rawtext[len(_extheader):].replace(b'i', b'1')
-    return text, True
+    return text, True, {}
 
 def writeprocessor(self, text):
     # False: the returned rawtext shouldn't be used to verify hash