Mercurial > hg > mercurial-source
diff mercurial/bundle2.py @ 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 (2014-05-24) |
parents | 7c5a85619dca |
children | 35095f332846 |
line wrap: on
line diff
--- a/mercurial/bundle2.py +++ b/mercurial/bundle2.py @@ -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):