changeset 21139:2b8c82f7f11d

bundle2: capabilities encoding
author Pierre-Yves David <pierre-yves.david@fb.com>
date Thu, 17 Apr 2014 01:44:53 -0400
parents f469879d27ec
children 4aeb8da68090
files mercurial/bundle2.py
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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