comparison mercurial/pushkey.py @ 43077:687b865b95ad

formatting: byteify all mercurial/ and hgext/ string literals Done with python3.7 contrib/byteify-strings.py -i $(hg files 'set:mercurial/**.py - mercurial/thirdparty/** + hgext/**.py - hgext/fsmonitor/pywatchman/** - mercurial/__init__.py') black -l 80 -t py33 -S $(hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**" - hgext/fsmonitor/pywatchman/**') # skip-blame mass-reformatting only Differential Revision: https://phab.mercurial-scm.org/D6972
author Augie Fackler <augie@google.com>
date Sun, 06 Oct 2019 09:48:39 -0400
parents 57875cf423c9
children d4ba4d51f85f
comparison
equal deleted inserted replaced
43076:2372284d9457 43077:687b865b95ad
16 16
17 17
18 def _nslist(repo): 18 def _nslist(repo):
19 n = {} 19 n = {}
20 for k in _namespaces: 20 for k in _namespaces:
21 n[k] = "" 21 n[k] = b""
22 if not obsolete.isenabled(repo, obsolete.exchangeopt): 22 if not obsolete.isenabled(repo, obsolete.exchangeopt):
23 n.pop('obsolete') 23 n.pop(b'obsolete')
24 return n 24 return n
25 25
26 26
27 _namespaces = { 27 _namespaces = {
28 "namespaces": (lambda *x: False, _nslist), 28 b"namespaces": (lambda *x: False, _nslist),
29 "bookmarks": (bookmarks.pushbookmark, bookmarks.listbookmarks), 29 b"bookmarks": (bookmarks.pushbookmark, bookmarks.listbookmarks),
30 "phases": (phases.pushphase, phases.listphases), 30 b"phases": (phases.pushphase, phases.listphases),
31 "obsolete": (obsolete.pushmarker, obsolete.listmarkers), 31 b"obsolete": (obsolete.pushmarker, obsolete.listmarkers),
32 } 32 }
33 33
34 34
35 def register(namespace, pushkey, listkeys): 35 def register(namespace, pushkey, listkeys):
36 _namespaces[namespace] = (pushkey, listkeys) 36 _namespaces[namespace] = (pushkey, listkeys)
57 decode = encoding.tolocal 57 decode = encoding.tolocal
58 58
59 59
60 def encodekeys(keys): 60 def encodekeys(keys):
61 """encode the content of a pushkey namespace for exchange over the wire""" 61 """encode the content of a pushkey namespace for exchange over the wire"""
62 return '\n'.join(['%s\t%s' % (encode(k), encode(v)) for k, v in keys]) 62 return b'\n'.join([b'%s\t%s' % (encode(k), encode(v)) for k, v in keys])
63 63
64 64
65 def decodekeys(data): 65 def decodekeys(data):
66 """decode the content of a pushkey namespace from exchange over the wire""" 66 """decode the content of a pushkey namespace from exchange over the wire"""
67 result = {} 67 result = {}
68 for l in data.splitlines(): 68 for l in data.splitlines():
69 k, v = l.split('\t') 69 k, v = l.split(b'\t')
70 result[decode(k)] = decode(v) 70 result[decode(k)] = decode(v)
71 return result 71 return result