Mercurial > public > mercurial-scm > hg
comparison mercurial/posix.py @ 17203:0cb55b5c19a3
util, posix: eliminate encodinglower and encodingupper
2ebe3d0ce91d claims this was needed "to avoid cyclic dependency", but there is
no cyclic dependency.
windows.py already imports encoding, posix.py can import it too, so we can
simply use encoding.upper in windows.py and in posix.py.
(this is a partial backout of 2ebe3d0ce91d)
author | Adrian Buehlmann <adrian@cadifra.com> |
---|---|
date | Wed, 18 Jul 2012 14:41:58 +0200 |
parents | 7002bb17cc5e |
children | fc24c10424d2 |
comparison
equal
deleted
inserted
replaced
17202:1ae119269ddc | 17203:0cb55b5c19a3 |
---|---|
4 # | 4 # |
5 # This software may be used and distributed according to the terms of the | 5 # This software may be used and distributed according to the terms of the |
6 # GNU General Public License version 2 or any later version. | 6 # GNU General Public License version 2 or any later version. |
7 | 7 |
8 from i18n import _ | 8 from i18n import _ |
9 import encoding | |
9 import os, sys, errno, stat, getpass, pwd, grp, tempfile, unicodedata | 10 import os, sys, errno, stat, getpass, pwd, grp, tempfile, unicodedata |
10 | 11 |
11 posixfile = open | 12 posixfile = open |
12 nulldev = '/dev/null' | 13 nulldev = '/dev/null' |
13 normpath = os.path.normpath | 14 normpath = os.path.normpath |
162 guaranteed to work for files, not directories.""" | 163 guaranteed to work for files, not directories.""" |
163 st1 = os.lstat(fpath1) | 164 st1 = os.lstat(fpath1) |
164 st2 = os.lstat(fpath2) | 165 st2 = os.lstat(fpath2) |
165 return st1.st_dev == st2.st_dev | 166 return st1.st_dev == st2.st_dev |
166 | 167 |
167 encodinglower = None | |
168 encodingupper = None | |
169 | |
170 # os.path.normcase is a no-op, which doesn't help us on non-native filesystems | 168 # os.path.normcase is a no-op, which doesn't help us on non-native filesystems |
171 def normcase(path): | 169 def normcase(path): |
172 return path.lower() | 170 return path.lower() |
173 | 171 |
174 if sys.platform == 'darwin': | 172 if sys.platform == 'darwin': |
253 # use upper-ing as normcase as same as NTFS workaround | 251 # use upper-ing as normcase as same as NTFS workaround |
254 def normcase(path): | 252 def normcase(path): |
255 pathlen = len(path) | 253 pathlen = len(path) |
256 if (pathlen == 0) or (path[0] != os.sep): | 254 if (pathlen == 0) or (path[0] != os.sep): |
257 # treat as relative | 255 # treat as relative |
258 return encodingupper(path) | 256 return encoding.upper(path) |
259 | 257 |
260 # to preserve case of mountpoint part | 258 # to preserve case of mountpoint part |
261 for mp in cygwinmountpoints: | 259 for mp in cygwinmountpoints: |
262 if not path.startswith(mp): | 260 if not path.startswith(mp): |
263 continue | 261 continue |
264 | 262 |
265 mplen = len(mp) | 263 mplen = len(mp) |
266 if mplen == pathlen: # mount point itself | 264 if mplen == pathlen: # mount point itself |
267 return mp | 265 return mp |
268 if path[mplen] == os.sep: | 266 if path[mplen] == os.sep: |
269 return mp + encodingupper(path[mplen:]) | 267 return mp + encoding.upper(path[mplen:]) |
270 | 268 |
271 return encodingupper(path) | 269 return encoding.upper(path) |
272 | 270 |
273 # Cygwin translates native ACLs to POSIX permissions, | 271 # Cygwin translates native ACLs to POSIX permissions, |
274 # but these translations are not supported by native | 272 # but these translations are not supported by native |
275 # tools, so the exec bit tends to be set erroneously. | 273 # tools, so the exec bit tends to be set erroneously. |
276 # Therefore, disable executable bit access on Cygwin. | 274 # Therefore, disable executable bit access on Cygwin. |