Patchwork D10778: changegroup: fix deltachunk API to be consistent from one class to another

login
register
mail settings
Submitter phabricator
Date May 28, 2021, 10:34 p.m.
Message ID <differential-rev-PHID-DREV-innd3n5x4kknytspiqkz-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49098/
State Superseded
Headers show

Comments

phabricator - May 28, 2021, 10:34 p.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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`.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/remotefilelog/shallowbundle.py
  mercurial/changegroup.py

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -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):
diff --git a/hgext/remotefilelog/shallowbundle.py b/hgext/remotefilelog/shallowbundle.py
--- a/hgext/remotefilelog/shallowbundle.py
+++ b/hgext/remotefilelog/shallowbundle.py
@@ -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