##// END OF EJS Templates
i18n: use encoding.lower/upper for encoding aware case folding...
FUJIWARA Katsunori -
r15672:2ebe3d0c stable
parent child Browse files
Show More
@@ -128,8 +128,6 b' def wrapname(name, wrapper):'
128 128 # they use result of os.path.split()
129 129 funcs = '''os.path.join os.path.split os.path.splitext
130 130 os.path.splitunc os.path.normpath os.makedirs
131 mercurial.windows.normcase
132 mercurial.util.normcase
133 131 mercurial.util.endswithsep mercurial.util.splitpath mercurial.util.checkcase
134 132 mercurial.util.fspath mercurial.util.pconvert mercurial.util.normpath
135 133 mercurial.util.checkwinfilename mercurial.util.checkosfilename'''
@@ -171,3 +171,22 b' def lower(s):'
171 171 return lu.encode(encoding)
172 172 except UnicodeError:
173 173 return s.lower() # we don't know how to fold this except in ASCII
174 except LookupError, k:
175 raise error.Abort(k, hint="please check your locale settings")
176
177 def upper(s):
178 "best-effort encoding-aware case-folding of local string s"
179 try:
180 if isinstance(s, localstr):
181 u = s._utf8.decode("utf-8")
182 else:
183 u = s.decode(encoding, encodingmode)
184
185 uu = u.upper()
186 if u == uu:
187 return s # preserve localstring
188 return uu.encode(encoding)
189 except UnicodeError:
190 return s.upper() # we don't know how to fold this except in ASCII
191 except LookupError, k:
192 raise error.Abort(k, hint="please check your locale settings")
@@ -164,6 +164,9 b' def samedevice(fpath1, fpath2):'
164 164 st2 = os.lstat(fpath2)
165 165 return st1.st_dev == st2.st_dev
166 166
167 encodinglower = None
168 encodingupper = None
169
167 170 # os.path.normcase is a no-op, which doesn't help us on non-native filesystems
168 171 def normcase(path):
169 172 return path.lower()
@@ -24,6 +24,9 b" if os.name == 'nt':"
24 24 else:
25 25 import posix as platform
26 26
27 platform.encodinglower = encoding.lower
28 platform.encodingupper = encoding.upper
29
27 30 cachestat = platform.cachestat
28 31 checkexec = platform.checkexec
29 32 checklink = platform.checklink
@@ -131,8 +131,11 b' def localpath(path):'
131 131 def normpath(path):
132 132 return pconvert(os.path.normpath(path))
133 133
134 encodinglower = None
135 encodingupper = None
136
134 137 def normcase(path):
135 return path.upper()
138 return encodingupper(path)
136 139
137 140 def realpath(path):
138 141 '''
General Comments 0
You need to be logged in to leave comments. Login now