changeset 35759:c24dad55ac19

bundle2: add support for a 'stream' parameter to 'getbundle' This parameter can be used to request a stream bundle.
author Boris Feld <boris.feld@octobus.net>
date Wed, 17 Jan 2018 16:36:23 +0100
parents b996ddf5963d
children 133a678673cb
files mercurial/exchange.py mercurial/wireproto.py
diffstat 2 files changed, 16 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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