# HG changeset patch # User Pierre-Yves David # Date 1397713493 14400 # Node ID 2b8c82f7f11df523bae55c7214733a281d413398 # Parent f469879d27ecfbe2fed9169731265f000b530271 bundle2: capabilities encoding diff -r f469879d27ec -r 2b8c82f7f11d mercurial/bundle2.py --- a/mercurial/bundle2.py Thu Apr 17 01:09:05 2014 -0400 +++ b/mercurial/bundle2.py Thu Apr 17 01:44:53 2014 -0400 @@ -356,6 +356,18 @@ caps[key] = vals return caps +def encodecaps(caps): + """encode a bundle2 caps dictionary into a bytes blob""" + chunks = [] + for ca in sorted(caps): + vals = caps[ca] + ca = urllib.quote(ca) + vals = [urllib.quote(v) for v in vals] + if vals: + ca = "%s=%s" % (ca, ','.join(vals)) + chunks.append(ca) + return '\n'.join(chunks) + class bundle20(object): """represent an outgoing bundle2 container