comparison mercurial/posix.py @ 27380:c7129ed280b8

mac: fix percent-encoding of non-utf-8 characters (issue4999)
author Matt Mackall <mpm@selenic.com>
date Sat, 12 Dec 2015 21:36:21 -0600
parents c220434a3461
children 3239e2fdd2e2
comparison
equal deleted inserted replaced
27379:2278870bb997 27380:c7129ed280b8
268 u = path.decode('utf-8') 268 u = path.decode('utf-8')
269 except UnicodeDecodeError: 269 except UnicodeDecodeError:
270 # OS X percent-encodes any bytes that aren't valid utf-8 270 # OS X percent-encodes any bytes that aren't valid utf-8
271 s = '' 271 s = ''
272 pos = 0 272 pos = 0
273 l = len(s) 273 l = len(path)
274 while pos < l: 274 while pos < l:
275 try: 275 try:
276 c = encoding.getutf8char(path, pos) 276 c = encoding.getutf8char(path, pos)
277 pos += len(c) 277 pos += len(c)
278 except ValueError: 278 except ValueError:
279 c = '%%%%02X' % path[pos] 279 c = '%%%02X' % ord(path[pos])
280 pos += 1 280 pos += 1
281 s += c 281 s += c
282 282
283 u = s.decode('utf-8') 283 u = s.decode('utf-8')
284 284