Submitter | Pierre-Yves David |
---|---|
Date | Aug. 4, 2014, 6:41 p.m. |
Message ID | <1f6ba804c429b73ec9ed.1407177693@marginatus.alto.octopoid.net> |
Download | mbox | patch |
Permalink | /patch/5247/ |
State | Accepted |
Headers | show |
Comments
On Mon, 2014-08-04 at 11:41 -0700, pierre-yves.david@ens-lyon.org wrote: > # HG changeset patch > # User Pierre-Yves David <pierre-yves.david@fb.com> > # Date 1401580109 25200 > # Sat May 31 16:48:29 2014 -0700 > # Node ID 1f6ba804c429b73ec9eda440deca788632ac3849 > # Parent d45398ff6b1cf799b0e76b0d1f8c3e30b0079ba9 > getbundle: add a ``cg`` boolean argument to control changegroup inclusion > > The ``getbundle`` function was initially design to return changegroup bundle. > However, bundle2 allow to transmit a wide range of data. Some of the bundle2 > request may not includes changegroup at all. > > Before this changeset, the client would request a changegroup for > ``heads=[nullid]`` and receives an empty changegroup. > > We introduce an official boolean parameters, ``cg``, that can be set to false to > disable changegroup generation on getbundle. A new bundle2 capabilities is > introduced to let the client known. These are queued for default, thanks.
Patch
diff --git a/mercurial/exchange.py b/mercurial/exchange.py --- a/mercurial/exchange.py +++ b/mercurial/exchange.py @@ -724,13 +724,17 @@ def getbundle(repo, source, heads=None, have a clearer idea of the API we what to query different data. 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') % ', '.join(sorted(kwargs.keys()))) return cg diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -180,11 +180,13 @@ class localrepository(object): requirements = ['revlogv1'] filtername = None 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 featuresetupfuncs = set() diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py --- a/mercurial/wireproto.py +++ b/mercurial/wireproto.py @@ -201,11 +201,12 @@ def unescapearg(escaped): # :csv: list of comma-separated values # :plain: string with no transformation needed. gboptsmap = {'heads': 'nodes', 'common': 'nodes', 'bundlecaps': 'csv', - 'listkeys': 'csv'} + 'listkeys': 'csv', + 'cg': 'boolean'} # client side class wirepeer(peer.peerrepository):