# HG changeset patch # User Pierre-Yves David # Date 1400790693 25200 # Node ID aed14bb165f38d09c1f8df7b1fbae7c221c5f0ff # Parent 17755dd8c5098c0cbea277e5b94c4b0d1378cafe bundle2: introduce a ``caps20to10`` function This function factors the creation of appropriate entries to use in ``bundlecaps`` argument of ``getbundle``. This cleans up code calling ``getbundle`` and helps its usage in more part of the code. diff -r 17755dd8c509 -r aed14bb165f3 mercurial/exchange.py --- a/mercurial/exchange.py Sat May 24 16:20:09 2014 -0700 +++ b/mercurial/exchange.py Thu May 22 13:31:33 2014 -0700 @@ -532,9 +532,7 @@ """pull data using bundle2 For now, the only supported data are changegroup.""" - kwargs = {'bundlecaps': set(['HG2X'])} - capsblob = bundle2.encodecaps(pullop.repo.bundle2caps) - kwargs['bundlecaps'].add('bundle2=' + urllib.quote(capsblob)) + kwargs = {'bundlecaps': caps20to10(pullop.repo)} # pulling changegroup pullop.todosteps.remove('changegroup') @@ -636,6 +634,13 @@ pullop.repo.invalidatevolatilesets() return tr +def caps20to10(repo): + """return a set with appropriate options to use bundle20 during getbundle""" + caps = set(['HG2X']) + capsblob = bundle2.encodecaps(repo.bundle2caps) + caps.add('bundle2=' + urllib.quote(capsblob)) + return caps + def getbundle(repo, source, heads=None, common=None, bundlecaps=None, **kwargs): """return a full bundle (with potentially multiple kind of parts)