mercurial/bundle2.py
changeset 21139 2b8c82f7f11d
parent 21138 f469879d27ec
child 21144 7a20fe8dc080
--- 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