bundle2: add support for a 'stream' parameter to 'getbundle'
authorBoris Feld <boris.feld@octobus.net>
Wed, 17 Jan 2018 16:36:23 +0100
changeset 35759 c24dad55ac19
parent 35758 b996ddf5963d
child 35760 133a678673cb
bundle2: add support for a 'stream' parameter to 'getbundle' This parameter can be used to request a stream bundle.
mercurial/exchange.py
mercurial/wireproto.py
--- a/mercurial/exchange.py	Wed Jan 17 16:35:22 2018 +0100
+++ b/mercurial/exchange.py	Wed Jan 17 16:36:23 2018 +0100
@@ -1747,6 +1747,19 @@
 
     return bundler.getchunks()
 
+@getbundle2partsgenerator('stream')
+def _getbundlestream(bundler, repo, source, bundlecaps=None,
+                     b2caps=None, heads=None, common=None, **kwargs):
+    if not kwargs.get('stream', False):
+        return
+    filecount, bytecount, it = streamclone.generatev2(repo)
+    requirements = ' '.join(repo.requirements)
+    part = bundler.newpart('stream', data=it)
+    part.addparam('bytecount', '%d' % bytecount, mandatory=True)
+    part.addparam('filecount', '%d' % filecount, mandatory=True)
+    part.addparam('requirements', requirements, mandatory=True)
+    part.addparam('version', 'v2', mandatory=True)
+
 @getbundle2partsgenerator('changegroup')
 def _getbundlechangegrouppart(bundler, repo, source, bundlecaps=None,
                               b2caps=None, heads=None, common=None, **kwargs):
--- a/mercurial/wireproto.py	Wed Jan 17 16:35:22 2018 +0100
+++ b/mercurial/wireproto.py	Wed Jan 17 16:36:23 2018 +0100
@@ -212,7 +212,9 @@
              'bundlecaps': 'scsv',
              'listkeys': 'csv',
              'cg': 'boolean',
-             'cbattempted': 'boolean'}
+             'cbattempted': 'boolean',
+             'stream': 'boolean',
+}
 
 # client side