flagprocessors: writetransform function take side data as parameter (API)
If we want some flag processors to be able to store sidedata it needs to be
actually fed that data.
Differential Revision: https://phab.mercurial-scm.org/D6816
--- a/hgext/lfs/wrapper.py Tue Sep 03 23:51:17 2019 +0200
+++ b/hgext/lfs/wrapper.py Wed Sep 04 00:53:27 2019 +0200
@@ -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:
--- a/mercurial/revlog.py Tue Sep 03 23:51:17 2019 +0200
+++ b/mercurial/revlog.py Wed Sep 04 00:53:27 2019 +0200
@@ -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):
--- a/mercurial/revlogutils/flagutil.py Tue Sep 03 23:51:17 2019 +0200
+++ b/mercurial/revlogutils/flagutil.py Wed Sep 04 00:53:27 2019 +0200
@@ -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
--- a/tests/flagprocessorext.py Tue Sep 03 23:51:17 2019 +0200
+++ b/tests/flagprocessorext.py Wed Sep 04 00:53:27 2019 +0200
@@ -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):
--- a/tests/test-revlog-raw.py Tue Sep 03 23:51:17 2019 +0200
+++ b/tests/test-revlog-raw.py Wed Sep 04 00:53:27 2019 +0200
@@ -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):