getbundle: add a ``cg`` boolean argument to control changegroup inclusion
The ``getbundle`` function was initially design to return a changegroup bundle.
However, bundle2 allows transmitting a wide range of data. Some bundle2
requests may not include a changegroup at all.
Before this changeset, the client would request a changegroup for
``heads=[nullid]`` and receive an empty changegroup.
We introduce an official boolean parameter, ``cg``, that can be set
to false to disable changegroup generation on getbundle. A new bundle2
capability is introduced to let the client know.
--- a/mercurial/exchange.py Thu May 22 17:20:52 2014 -0700
+++ b/mercurial/exchange.py Sat May 31 16:48:29 2014 -0700
@@ -726,9 +726,13 @@
The implementation is at a very early stage and will get massive rework
when the API of bundle is refined.
"""
- # build changegroup bundle here.
- cg = changegroup.getbundle(repo, source, heads=heads,
- common=common, bundlecaps=bundlecaps)
+ cg = None
+ if kwargs.get('cg', True):
+ # build changegroup bundle here.
+ cg = changegroup.getbundle(repo, source, heads=heads,
+ common=common, bundlecaps=bundlecaps)
+ elif 'HG2X' not in bundlecaps:
+ raise ValueError(_('request for bundle10 must include changegroup'))
if bundlecaps is None or 'HG2X' not in bundlecaps:
if kwargs:
raise ValueError(_('unsupported getbundle arguments: %s')
--- a/mercurial/localrepo.py Thu May 22 17:20:52 2014 -0700
+++ b/mercurial/localrepo.py Sat May 31 16:48:29 2014 -0700
@@ -182,7 +182,9 @@
bundle2caps = {'HG2X': (),
'b2x:listkeys': (),
- 'b2x:pushkey': ()}
+ 'b2x:pushkey': (),
+ 'b2x:changegroup': (),
+ }
# a list of (ui, featureset) functions.
# only functions defined in module of enabled extensions are invoked
--- a/mercurial/wireproto.py Thu May 22 17:20:52 2014 -0700
+++ b/mercurial/wireproto.py Sat May 31 16:48:29 2014 -0700
@@ -203,7 +203,8 @@
gboptsmap = {'heads': 'nodes',
'common': 'nodes',
'bundlecaps': 'csv',
- 'listkeys': 'csv'}
+ 'listkeys': 'csv',
+ 'cg': 'boolean'}
# client side