Mercurial > hg
comparison mercurial/store.py @ 49284:d44e3c45f0e4
py3: replace `pycompat.xrange` by `range`
author | Manuel Jacob <me@manueljacob.de> |
---|---|
date | Sun, 29 May 2022 15:17:27 +0200 |
parents | 642e31cb55f0 |
children | 2e726c934fcd |
comparison
equal
deleted
inserted
replaced
49283:44b26349127b | 49284:d44e3c45f0e4 |
---|---|
148 dmap[v] = k | 148 dmap[v] = k |
149 | 149 |
150 def decode(s): | 150 def decode(s): |
151 i = 0 | 151 i = 0 |
152 while i < len(s): | 152 while i < len(s): |
153 for l in pycompat.xrange(1, 4): | 153 for l in range(1, 4): |
154 try: | 154 try: |
155 yield dmap[s[i : i + l]] | 155 yield dmap[s[i : i + l]] |
156 i += l | 156 i += l |
157 break | 157 break |
158 except KeyError: | 158 except KeyError: |
159 pass | 159 pass |
160 else: | 160 else: |
161 raise KeyError | 161 raise KeyError |
162 | 162 |
163 return ( | 163 return ( |
164 lambda s: b''.join( | 164 lambda s: b''.join([cmap[s[c : c + 1]] for c in range(len(s))]), |
165 [cmap[s[c : c + 1]] for c in pycompat.xrange(len(s))] | |
166 ), | |
167 lambda s: b''.join(list(decode(s))), | 165 lambda s: b''.join(list(decode(s))), |
168 ) | 166 ) |
169 | 167 |
170 | 168 |
171 _encodefname, _decodefname = _buildencodefun() | 169 _encodefname, _decodefname = _buildencodefun() |
198 'hello~3aworld~3f' | 196 'hello~3aworld~3f' |
199 >>> f(b'the\\x07quick\\xADshot') | 197 >>> f(b'the\\x07quick\\xADshot') |
200 'the~07quick~adshot' | 198 'the~07quick~adshot' |
201 """ | 199 """ |
202 xchr = pycompat.bytechr | 200 xchr = pycompat.bytechr |
203 cmap = {xchr(x): xchr(x) for x in pycompat.xrange(127)} | 201 cmap = {xchr(x): xchr(x) for x in range(127)} |
204 for x in _reserved(): | 202 for x in _reserved(): |
205 cmap[xchr(x)] = b"~%02x" % x | 203 cmap[xchr(x)] = b"~%02x" % x |
206 for x in range(ord(b"A"), ord(b"Z") + 1): | 204 for x in range(ord(b"A"), ord(b"Z") + 1): |
207 cmap[xchr(x)] = xchr(x).lower() | 205 cmap[xchr(x)] = xchr(x).lower() |
208 | 206 |