changeset 47340:3f00665bbea0

changegroup: fix deltachunk API to be consistent from one class to another Depending of the subclass the 8th index of `chunkdata` items was either a sidedata dict of a proto_flags integer. We have not fixed the inconsistency and we already return fixed "delta" items from `deltaiter`. Differential Revision: https://phab.mercurial-scm.org/D10778
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 28 May 2021 20:00:27 +0200
parents 43f6a7bb4e12
children 24ea3ef35238
files hgext/remotefilelog/shallowbundle.py mercurial/changegroup.py
diffstat 2 files changed, 51 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/remotefilelog/shallowbundle.py	Thu May 27 12:10:59 2021 -0400
+++ b/hgext/remotefilelog/shallowbundle.py	Fri May 28 20:00:27 2021 +0200
@@ -225,7 +225,17 @@
 
         chain = None
         while True:
-            # returns: (node, p1, p2, cs, deltabase, delta, flags) or None
+            # returns: None or (
+            #   node,
+            #   p1,
+            #   p2,
+            #   cs,
+            #   deltabase,
+            #   delta,
+            #   flags,
+            #   sidedata,
+            #   proto_flags
+            # )
             revisiondata = source.deltachunk(chain)
             if not revisiondata:
                 break
@@ -263,7 +273,7 @@
     prefetchfiles = []
     for f, node in queue:
         revisiondata = revisiondatas[(f, node)]
-        # revisiondata: (node, p1, p2, cs, deltabase, delta, flags)
+        # revisiondata: (node, p1, p2, cs, deltabase, delta, flags, sdata, pfl)
         dependents = [revisiondata[1], revisiondata[2], revisiondata[4]]
 
         for dependent in dependents:
@@ -287,8 +297,18 @@
         fl = repo.file(f)
 
         revisiondata = revisiondatas[(f, node)]
-        # revisiondata: (node, p1, p2, cs, deltabase, delta, flags)
-        node, p1, p2, linknode, deltabase, delta, flags, sidedata = revisiondata
+        # revisiondata: (node, p1, p2, cs, deltabase, delta, flags, sdata, pfl)
+        (
+            node,
+            p1,
+            p2,
+            linknode,
+            deltabase,
+            delta,
+            flags,
+            sidedata,
+            proto_flags,
+        ) = revisiondata
 
         if not available(f, node, f, deltabase):
             continue
--- a/mercurial/changegroup.py	Thu May 27 12:10:59 2021 -0400
+++ b/mercurial/changegroup.py	Fri May 28 20:00:27 2021 +0200
@@ -199,6 +199,7 @@
         return node, p1, p2, deltabase, cs, flags, protocol_flags
 
     def deltachunk(self, prevnode):
+        # Chunkdata: (node, p1, p2, cs, deltabase, delta, flags, sidedata, proto_flags)
         l = self._chunklength()
         if not l:
             return {}
@@ -207,7 +208,7 @@
         delta = readexactly(self._stream, l - self.deltaheadersize)
         header = self._deltaheader(header, prevnode)
         node, p1, p2, deltabase, cs, flags, protocol_flags = header
-        return node, p1, p2, cs, deltabase, delta, flags, protocol_flags
+        return node, p1, p2, cs, deltabase, delta, flags, {}, protocol_flags
 
     def getchunks(self):
         """returns all the chunks contains in the bundle
@@ -583,8 +584,8 @@
         """
         chain = None
         for chunkdata in iter(lambda: self.deltachunk(chain), {}):
-            # Chunkdata: (node, p1, p2, cs, deltabase, delta, flags, sidedata)
-            yield chunkdata
+            # Chunkdata: (node, p1, p2, cs, deltabase, delta, flags, sidedata, proto_flags)
+            yield chunkdata[:8]
             chain = chunkdata[0]
 
 
@@ -659,14 +660,35 @@
         if not res:
             return res
 
-        (node, p1, p2, cs, deltabase, delta, flags, protocol_flags) = res
+        (
+            node,
+            p1,
+            p2,
+            cs,
+            deltabase,
+            delta,
+            flags,
+            sidedata,
+            protocol_flags,
+        ) = res
+        assert not sidedata
 
         sidedata = {}
         if protocol_flags & storageutil.CG_FLAG_SIDEDATA:
             sidedata_raw = getchunk(self._stream)
             sidedata = sidedatamod.deserialize_sidedata(sidedata_raw)
 
-        return node, p1, p2, cs, deltabase, delta, flags, sidedata
+        return (
+            node,
+            p1,
+            p2,
+            cs,
+            deltabase,
+            delta,
+            flags,
+            sidedata,
+            protocol_flags,
+        )
 
 
 class headerlessfixup(object):