comparison mercurial/store.py @ 31253:64596338ba10

py3: factor out bytechr() function I also changed xrange(127) to range(127) as the number is relatively small.
author Yuya Nishihara <yuya@tcha.org>
date Wed, 08 Mar 2017 22:30:12 +0900
parents 9b7a2ef4f27c
children 50cd81346ad4
comparison
equal deleted inserted replaced
31252:e7a35f18d91f 31253:64596338ba10
97 'the~07quick~adshot' 97 'the~07quick~adshot'
98 >>> dec('the~07quick~adshot') 98 >>> dec('the~07quick~adshot')
99 'the\\x07quick\\xadshot' 99 'the\\x07quick\\xadshot'
100 ''' 100 '''
101 e = '_' 101 e = '_'
102 if pycompat.ispy3: 102 xchr = pycompat.bytechr
103 xchr = lambda x: bytes([x]) 103 asciistr = list(map(xchr, range(127)))
104 asciistr = [bytes([a]) for a in range(127)]
105 else:
106 xchr = chr
107 asciistr = map(chr, xrange(127))
108 capitals = list(range(ord("A"), ord("Z") + 1)) 104 capitals = list(range(ord("A"), ord("Z") + 1))
109 105
110 cmap = dict((x, x) for x in asciistr) 106 cmap = dict((x, x) for x in asciistr)
111 for x in _reserved(): 107 for x in _reserved():
112 cmap[xchr(x)] = "~%02x" % x 108 cmap[xchr(x)] = "~%02x" % x