store: slice over a bytestring to get characters instead of ascii values
On Python 2,
>>> a = b'abc'
>>> a[1]
'b'
Whereas on python 3,
>>> a = b'abc'
>>> a[1]
98
>>> a[1:2]
b'b'
This does not change behaviour on python 2.
--- a/mercurial/store.py Thu Mar 02 13:27:42 2017 +0100
+++ b/mercurial/store.py Wed Mar 08 00:40:15 2017 +0530
@@ -101,7 +101,7 @@
e = '_'
if pycompat.ispy3:
xchr = lambda x: bytes([x])
- asciistr = [bytes(a) for a in range(127)]
+ asciistr = [bytes([a]) for a in range(127)]
else:
xchr = chr
asciistr = map(chr, xrange(127))
@@ -128,7 +128,7 @@
pass
else:
raise KeyError
- return (lambda s: ''.join([cmap[c] for c in s]),
+ return (lambda s: ''.join([cmap[s[c:c + 1]] for c in xrange(len(s))]),
lambda s: ''.join(list(decode(s))))
_encodefname, _decodefname = _buildencodefun()