bundle2: capabilities encoding
authorPierre-Yves David <pierre-yves.david@fb.com>
Thu, 17 Apr 2014 01:44:53 -0400
changeset 21139 2b8c82f7f11d
parent 21138 f469879d27ec
child 21140 4aeb8da68090
bundle2: capabilities encoding
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