Mercurial > hg
changeset 21644:17755dd8c509
bundle2: introduce a bundle2caps function
The process of decoding remote bundle2caps blob into a dictionary is cumbersome.
We move it into a small helper function. This will clarify code that reads
bundle2 capabilities of peers and helps using it in new places.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Sat, 24 May 2014 16:20:09 -0700 |
parents | 75ff093d2763 |
children | aed14bb165f3 |
files | mercurial/bundle2.py mercurial/exchange.py |
diffstat | 2 files changed, 8 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/bundle2.py Thu May 22 12:58:07 2014 -0700 +++ b/mercurial/bundle2.py Sat May 24 16:20:09 2014 -0700 @@ -769,6 +769,13 @@ self.consumed = True return data +def bundle2caps(remote): + """return the bundlecapabilities of a peer as dict""" + raw = remote.capable('bundle2-exp') + if not raw and raw != '': + return {} + capsblob = urllib.unquote(remote.capable('bundle2-exp')) + return decodecaps(capsblob) @parthandler('b2x:changegroup') def handlechangegroup(op, inpart):
--- a/mercurial/exchange.py Thu May 22 12:58:07 2014 -0700 +++ b/mercurial/exchange.py Sat May 24 16:20:09 2014 -0700 @@ -208,9 +208,7 @@ The only currently supported type of data is changegroup but this will evolve in the future.""" - capsblob = urllib.unquote(pushop.remote.capable('bundle2-exp')) - caps = bundle2.decodecaps(capsblob) - bundler = bundle2.bundle20(pushop.ui, caps) + bundler = bundle2.bundle20(pushop.ui, bundle2.bundle2caps(pushop.remote)) # create reply capability capsblob = bundle2.encodecaps(pushop.repo.bundle2caps) bundler.newpart('b2x:replycaps', data=capsblob)