Mercurial > hg
changeset 21652:ed6e61eaebc0
pushkey: introduce an ``decodekeys`` 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 15:00:20 -0700 |
parents | 3aae044408aa |
children | 4188cae727ce |
files | mercurial/pushkey.py |
diffstat | 1 files changed, 8 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/pushkey.py Tue May 27 15:00:08 2014 -0700 +++ b/mercurial/pushkey.py Tue May 27 15:00:20 2014 -0700 @@ -41,3 +41,11 @@ """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