comparison mercurial/encoding.py @ 32339:7040f5131454

encoding: use i.startswith() instead of i[0] to eliminate py2/3 divergence
author Yuya Nishihara <yuya@tcha.org>
date Tue, 16 May 2017 23:36:38 +0900
parents bd872f64a8ba
children df448de7cf3b
comparison
equal deleted inserted replaced
32338:779a1ae6d0d9 32339:7040f5131454
27 # sanity. 27 # sanity.
28 _ignore = [unichr(int(x, 16)).encode("utf-8") for x in 28 _ignore = [unichr(int(x, 16)).encode("utf-8") for x in
29 "200c 200d 200e 200f 202a 202b 202c 202d 202e " 29 "200c 200d 200e 200f 202a 202b 202c 202d 202e "
30 "206a 206b 206c 206d 206e 206f feff".split()] 30 "206a 206b 206c 206d 206e 206f feff".split()]
31 # verify the next function will work 31 # verify the next function will work
32 if pycompat.ispy3: 32 assert all(i.startswith(("\xe2", "\xef")) for i in _ignore)
33 assert set(i[0] for i in _ignore) == {ord(b'\xe2'), ord(b'\xef')}
34 else:
35 assert set(i[0] for i in _ignore) == {"\xe2", "\xef"}
36 33
37 def hfsignoreclean(s): 34 def hfsignoreclean(s):
38 """Remove codepoints ignored by HFS+ from s. 35 """Remove codepoints ignored by HFS+ from s.
39 36
40 >>> hfsignoreclean(u'.h\u200cg'.encode('utf-8')) 37 >>> hfsignoreclean(u'.h\u200cg'.encode('utf-8'))