# HG changeset patch # User Pierre-Yves David # Date 2014-05-27 22:43:09 # Node ID 0ff44e06275da28a804e9a2e34e7d7e65ca32fea # Parent 36200dc6b3bd084eae62541f1989ad6903c6d37c getbundle: support of listkeys argument when bundle2 is used A new ``listkeys`` is supported by getbundle. It is a list of namespaces whose content should be included in the bundle. An appropriate entry has been added to the wireproto map of getbundle arguments and a new bundle2 capability is advertised. There are still no codes that request such parts in core mercurial. diff --git a/mercurial/exchange.py b/mercurial/exchange.py --- a/mercurial/exchange.py +++ b/mercurial/exchange.py @@ -9,7 +9,7 @@ from i18n import _ from node import hex, nullid import errno, urllib import util, scmutil, changegroup, base85, error -import discovery, phases, obsolete, bookmarks, bundle2 +import discovery, phases, obsolete, bookmarks, bundle2, pushkey def readbundle(ui, fh, fname, vfs=None): header = changegroup.readexactly(fh, 4) @@ -678,6 +678,12 @@ def getbundle(repo, source, heads=None, bundler = bundle2.bundle20(repo.ui, b2caps) if cg: bundler.newpart('b2x:changegroup', data=cg.getchunks()) + listkeys = kwargs.get('listkeys', ()) + for namespace in listkeys: + part = bundler.newpart('b2x:listkeys') + part.addparam('namespace', namespace) + keys = repo.listkeys(namespace).items() + part.data = pushkey.encodekeys(keys) _getbundleextrapart(bundler, repo, source, heads=heads, common=common, bundlecaps=bundlecaps, **kwargs) return util.chunkbuffer(bundler.getchunks()) diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -180,7 +180,8 @@ class localrepository(object): requirements = ['revlogv1'] filtername = None - bundle2caps = {'HG2X': ()} + bundle2caps = {'HG2X': (), + 'b2x:listkeys': ()} # a list of (ui, featureset) functions. # only functions defined in module of enabled extensions are invoked diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py --- a/mercurial/wireproto.py +++ b/mercurial/wireproto.py @@ -202,7 +202,8 @@ def unescapearg(escaped): # :plain: string with no transformation needed. gboptsmap = {'heads': 'nodes', 'common': 'nodes', - 'bundlecaps': 'csv'} + 'bundlecaps': 'csv', + 'listkeys': 'csv'} # client side