Mercurial > hg
comparison mercurial/pushkey.py @ 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 | a2c7ae21e8f4 |
children | a319842539f5 |
comparison
equal
deleted
inserted
replaced
21651:3aae044408aa | 21652:ed6e61eaebc0 |
---|---|
39 | 39 |
40 def encodekeys(keys): | 40 def encodekeys(keys): |
41 """encode the content of a pushkey namespace for exchange over the wire""" | 41 """encode the content of a pushkey namespace for exchange over the wire""" |
42 enc = encoding.fromlocal | 42 enc = encoding.fromlocal |
43 return '\n'.join(['%s\t%s' % (enc(k), enc(v)) for k, v in keys]) | 43 return '\n'.join(['%s\t%s' % (enc(k), enc(v)) for k, v in keys]) |
44 | |
45 def decodekeys(data): | |
46 """decode the content of a pushkey namespace from exchange over the wire""" | |
47 result = {} | |
48 for l in data.splitlines(): | |
49 k, v = l.split('\t') | |
50 result[encoding.tolocal(k)] = encoding.tolocal(v) | |
51 return result |