Patchwork [6,of,8] changegroup: give a way to includes header in getchunks

login
register
mail settings
Submitter Pierre-Yves David
Date April 11, 2014, 10:06 p.m.
Message ID <95eaf9fabeb354ac0dc6.1397253963@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/4289/
State Accepted
Headers show

Comments

Pierre-Yves David - April 11, 2014, 10:06 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1397224885 25200
#      Fri Apr 11 07:01:25 2014 -0700
# Node ID 95eaf9fabeb354ac0dc6f924ce1482e9a8bf1537
# Parent  6eef726e8e85dd6011fc61951c6dc7e4984df721
changegroup: give a way to includes header in getchunks

For bundle2 we want a simple way to stream a full changegroup. We need a header
for that. We add the option for `unbundle10` to do this. This stay optional
because `writebundle` may use compression and need to write its own header.

When we use an header, we use "HG10UN", as `getchunks` yield uncompressed chunk.
We rely on compression of the container for now.
Pierre-Yves David - April 12, 2014, 9:24 p.m.
On 04/11/2014 06:06 PM, pierre-yves.david@ens-lyon.org wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1397224885 25200
> #      Fri Apr 11 07:01:25 2014 -0700
> # Node ID 95eaf9fabeb354ac0dc6f924ce1482e9a8bf1537
> # Parent  6eef726e8e85dd6011fc61951c6dc7e4984df721
> changegroup: give a way to includes header in getchunks

This one have been dropped

Patch

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -89,11 +89,11 @@  def writebundle(cg, filename, bundletype
         # in case of sshrepo because we don't know the end of the stream
 
         # an empty chunkgroup is the end of the changegroup
         # a changegroup has at least 2 chunkgroups (changelog and manifest).
         # after that, an empty chunkgroup is the end of the changegroup
-        for chunk in cg.getchunks():
+        for chunk in cg.getchunks(includeheader=False):
             fh.write(z.compress(chunk))
         fh.write(z.flush())
         cleanup = None
         return filename
     finally:
@@ -185,20 +185,23 @@  class unbundle10(object):
         delta = readexactly(self._stream, l - self.deltaheadersize)
         node, p1, p2, deltabase, cs = self._deltaheader(header, prevnode)
         return {'node': node, 'p1': p1, 'p2': p2, 'cs': cs,
                 'deltabase': deltabase, 'delta': delta}
 
-    def getchunks(self):
+    def getchunks(self, includeheader=True):
         """returns all the chunks contains in the bundle
 
         Used when you need to forward the binary stream to a file or another
         network API. To do so, it parse the changegroup data, otherwise it will
         block in case of sshrepo because it don't know the end of the stream.
         """
         # an empty chunkgroup is the end of the changegroup
         # a changegroup has at least 2 chunkgroups (changelog and manifest).
         # after that, an empty chunkgroup is the end of the changegroup
+        if includeheader:
+            # do not use self._type as yielded chunk are not compressed
+            yield 'HG10UN'
         empty = False
         count = 0
         while not empty or count <= 2:
             empty = True
             count += 1