Patchwork [06,of,14] bundle2: add support for a 'stream' parameter to 'getbundle'

login
register
mail settings
Submitter Boris Feld
Date Jan. 18, 2018, 11:21 a.m.
Message ID <dcf85b8c86b8e9e55d13.1516274492@FB>
Download mbox | patch
Permalink /patch/26848/
State Superseded
Headers show

Comments

Boris Feld - Jan. 18, 2018, 11:21 a.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1516203383 -3600
#      Wed Jan 17 16:36:23 2018 +0100
# Node ID dcf85b8c86b8e9e55d1393c070fad04fb5de81a7
# Parent  92bb0655adc8dd59102b04a2cdcfdbbe37324f41
# EXP-Topic b2-stream
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r dcf85b8c86b8
bundle2: add support for a 'stream' parameter to 'getbundle'

This parameter can be used to request a stream bundle.

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1747,6 +1747,19 @@  def getbundlechunks(repo, source, heads=
 
     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):
diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py
--- a/mercurial/wireproto.py
+++ b/mercurial/wireproto.py
@@ -212,7 +212,9 @@  gboptsmap = {'heads':  'nodes',
              'bundlecaps': 'scsv',
              'listkeys': 'csv',
              'cg': 'boolean',
-             'cbattempted': 'boolean'}
+             'cbattempted': 'boolean',
+             'stream': 'boolean',
+}
 
 # client side