comparison mercurial/pushkey.py @ 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 59c14bf5a48c
children ed6e61eaebc0
comparison
equal deleted inserted replaced
21649:3bfadd70550b 21650:a2c7ae21e8f4
3 # Copyright 2010 Matt Mackall <mpm@selenic.com> 3 # Copyright 2010 Matt Mackall <mpm@selenic.com>
4 # 4 #
5 # This software may be used and distributed according to the terms of the 5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version. 6 # GNU General Public License version 2 or any later version.
7 7
8 import bookmarks, phases, obsolete 8 import bookmarks, phases, obsolete, encoding
9 9
10 def _nslist(repo): 10 def _nslist(repo):
11 n = {} 11 n = {}
12 for k in _namespaces: 12 for k in _namespaces:
13 n[k] = "" 13 n[k] = ""
35 def list(repo, namespace): 35 def list(repo, namespace):
36 '''return a dict''' 36 '''return a dict'''
37 lk = _get(namespace)[1] 37 lk = _get(namespace)[1]
38 return lk(repo) 38 return lk(repo)
39 39
40 def encodekeys(keys):
41 """encode the content of a pushkey namespace for exchange over the wire"""
42 enc = encoding.fromlocal
43 return '\n'.join(['%s\t%s' % (enc(k), enc(v)) for k, v in keys])