Patchwork D6813: flagprocessors: have the read transform function return side data (API)

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

Comments

phabricator - Sept. 7, 2019, 9:29 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
  This makes it possible for flag processors to -read- flag data.

REPOSITORY
  rHG Mercurial

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

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
@@ -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
diff --git a/tests/flagprocessorext.py b/tests/flagprocessorext.py
--- a/tests/flagprocessorext.py
+++ b/tests/flagprocessorext.py
@@ -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,
         )
diff --git a/mercurial/revlogutils/flagutil.py b/mercurial/revlogutils/flagutil.py
--- a/mercurial/revlogutils/flagutil.py
+++ b/mercurial/revlogutils/flagutil.py
@@ -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)
+                        sidedata.update(s)
                     else: # write operation
                         text, vhash = writetransform(self, text)
                 validatehash = validatehash and vhash
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -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
diff --git a/hgext/lfs/wrapper.py b/hgext/lfs/wrapper.py
--- a/hgext/lfs/wrapper.py
+++ b/hgext/lfs/wrapper.py
@@ -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)