This will let us mitigate the drive letter capitalization hell.
See inline comment for details.
Alphare |
hg-reviewers |
This will let us mitigate the drive letter capitalization hell.
See inline comment for details.
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/posix.py (2 lines) | |||
M | mercurial/util.py (3 lines) | |||
M | mercurial/windows.py (19 lines) |
Status | Author | Revision | |
---|---|---|---|
Closed | Alphare | ||
Closed | marmoute | ||
Abandoned | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | D11067 windows: use abspath in url | |
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | Alphare | ||
Closed | Alphare |
policy, | policy, | ||||
pycompat, | pycompat, | ||||
) | ) | ||||
osutil = policy.importmod('osutil') | osutil = policy.importmod('osutil') | ||||
normpath = os.path.normpath | normpath = os.path.normpath | ||||
samestat = os.path.samestat | samestat = os.path.samestat | ||||
abspath = os.path.abspath # re-exports | |||||
try: | try: | ||||
oslink = os.link | oslink = os.link | ||||
except AttributeError: | except AttributeError: | ||||
# Some platforms build Python without os.link on systems that are | # Some platforms build Python without os.link on systems that are | ||||
# vaguely unix-like but don't have hardlink support. For those | # vaguely unix-like but don't have hardlink support. For those | ||||
# poor souls, just say we tried and that it failed so we fall back | # poor souls, just say we tried and that it failed so we fall back | ||||
# to copies. | # to copies. | ||||
def oslink(src, dst): | def oslink(src, dst): |
if pycompat.iswindows: | if pycompat.iswindows: | ||||
from . import windows as platform | from . import windows as platform | ||||
else: | else: | ||||
from . import posix as platform | from . import posix as platform | ||||
_ = i18n._ | _ = i18n._ | ||||
abspath = platform.abspath | |||||
bindunixsocket = platform.bindunixsocket | bindunixsocket = platform.bindunixsocket | ||||
cachestat = platform.cachestat | cachestat = platform.cachestat | ||||
checkexec = platform.checkexec | checkexec = platform.checkexec | ||||
checklink = platform.checklink | checklink = platform.checklink | ||||
copymode = platform.copymode | copymode = platform.copymode | ||||
expandglobs = platform.expandglobs | expandglobs = platform.expandglobs | ||||
getfsmountpoint = platform.getfsmountpoint | getfsmountpoint = platform.getfsmountpoint | ||||
getfstype = platform.getfstype | getfstype = platform.getfstype | ||||
""" | """ | ||||
try: | try: | ||||
makedir(name, notindexed) | makedir(name, notindexed) | ||||
except OSError as err: | except OSError as err: | ||||
if err.errno == errno.EEXIST: | if err.errno == errno.EEXIST: | ||||
return | return | ||||
if err.errno != errno.ENOENT or not name: | if err.errno != errno.ENOENT or not name: | ||||
raise | raise | ||||
parent = os.path.dirname(os.path.abspath(name)) | parent = os.path.dirname(abspath(name)) | ||||
if parent == name: | if parent == name: | ||||
raise | raise | ||||
makedirs(parent, mode, notindexed) | makedirs(parent, mode, notindexed) | ||||
try: | try: | ||||
makedir(name, notindexed) | makedir(name, notindexed) | ||||
except OSError as err: | except OSError as err: | ||||
# Catch EEXIST to handle races | # Catch EEXIST to handle races | ||||
if err.errno == errno.EEXIST: | if err.errno == errno.EEXIST: |
def normpath(path): | def normpath(path): | ||||
return pconvert(os.path.normpath(path)) | return pconvert(os.path.normpath(path)) | ||||
def normcase(path): | def normcase(path): | ||||
return encoding.upper(path) # NTFS compares via upper() | return encoding.upper(path) # NTFS compares via upper() | ||||
DRIVE_RE_B = re.compile(b'^[a-z]:') | |||||
DRIVE_RE_S = re.compile('^[a-z]:') | |||||
def abspath(path): | |||||
abs_path = os.path.abspath(path) # re-exports | |||||
# Python on Windows is inconsistent regarding the capitalization of drive | |||||
# letter and this cause issue with various path comparison along the way. | |||||
# So we normalize the drive later to upper case here. | |||||
# | |||||
# See https://bugs.python.org/issue40368 for and example of this hell. | |||||
if isinstance(abs_path, bytes): | |||||
if DRIVE_RE_B.match(abs_path): | |||||
abs_path = abs_path[0:1].upper() + abs_path[1:] | |||||
elif DRIVE_RE_S.match(abs_path): | |||||
abs_path = abs_path[0:1].upper() + abs_path[1:] | |||||
return abs_path | |||||
# see posix.py for definitions | # see posix.py for definitions | ||||
normcasespec = encoding.normcasespecs.upper | normcasespec = encoding.normcasespecs.upper | ||||
normcasefallback = encoding.upperfallback | normcasefallback = encoding.upperfallback | ||||
def samestat(s1, s2): | def samestat(s1, s2): | ||||
return False | return False | ||||