changeset 21650:a2c7ae21e8f4

pushkey: introduce an ``encodekeys`` function This function provides a standardized way to exchange pushkey content over the wire.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Tue, 27 May 2014 14:57:28 -0700
parents 3bfadd70550b
children 3aae044408aa
files mercurial/pushkey.py
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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])