pushkey: introduce an ``encodekeys`` function
authorPierre-Yves David <pierre-yves.david@fb.com>
Tue, 27 May 2014 14:57:28 -0700
changeset 21650 a2c7ae21e8f4
parent 21649 3bfadd70550b
child 21651 3aae044408aa
pushkey: introduce an ``encodekeys`` function This function provides a standardized way to exchange pushkey content over the wire.
mercurial/pushkey.py
--- a/mercurial/pushkey.py	Tue May 27 13:44:16 2014 -0700
+++ b/mercurial/pushkey.py	Tue May 27 14:57:28 2014 -0700
@@ -5,7 +5,7 @@
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
-import bookmarks, phases, obsolete
+import bookmarks, phases, obsolete, encoding
 
 def _nslist(repo):
     n = {}
@@ -37,3 +37,7 @@
     lk = _get(namespace)[1]
     return lk(repo)
 
+def encodekeys(keys):
+    """encode the content of a pushkey namespace for exchange over the wire"""
+    enc = encoding.fromlocal
+    return '\n'.join(['%s\t%s' % (enc(k), enc(v)) for k, v in keys])