pushkey: introduce an ``encodekeys`` function
This function provides a standardized way to exchange pushkey content over
the wire.
--- 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])