# HG changeset patch # User Pierre-Yves David # Date 2014-05-27 21:57:28 # Node ID a2c7ae21e8f4d690e0d3f29879a513776a02ea9a # Parent 3bfadd70550b7527ec76f5e7854983535e2ad7e0 pushkey: introduce an ``encodekeys`` function This function provides a standardized way to exchange pushkey content over the wire. diff --git a/mercurial/pushkey.py b/mercurial/pushkey.py --- a/mercurial/pushkey.py +++ b/mercurial/pushkey.py @@ -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 @@ def list(repo, namespace): 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])