# HG changeset patch # User Pierre-Yves David # Date 2014-05-27 22:00:20 # Node ID ed6e61eaebc0b7ad4303b2ed149c1127a7b96e6e # Parent 3aae044408aac80ae2c17bd0e0ca26554d37ffba pushkey: introduce an ``decodekeys`` 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 @@ -41,3 +41,11 @@ 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]) + +def decodekeys(data): + """decode the content of a pushkey namespace from exchange over the wire""" + result = {} + for l in data.splitlines(): + k, v = l.split('\t') + result[encoding.tolocal(k)] = encoding.tolocal(v) + return result