--- a/mercurial/posix.py Fri Dec 16 21:09:40 2011 +0900
+++ b/mercurial/posix.py Fri Dec 16 21:21:08 2011 +0900
@@ -238,6 +238,38 @@
# Fallback to the likely inadequate Python builtin function.
realpath = os.path.realpath
+if sys.platform == 'cygwin':
+ # workaround for cygwin, in which mount point part of path is
+ # treated as case sensitive, even though underlying NTFS is case
+ # insensitive.
+
+ # default mount points
+ cygwinmountpoints = sorted([
+ "/usr/bin",
+ "/usr/lib",
+ "/cygdrive",
+ ], reverse=True)
+
+ # use upper-ing as normcase as same as NTFS workaround
+ def normcase(path):
+ pathlen = len(path)
+ if (pathlen == 0) or (path[0] != os.sep):
+ # treat as relative
+ return encodingupper(path)
+
+ # to preserve case of mountpoint part
+ for mp in cygwinmountpoints:
+ if not path.startswith(mp):
+ continue
+
+ mplen = len(mp)
+ if mplen == pathlen: # mount point itself
+ return mp
+ if path[mplen] == os.sep:
+ return mp + encodingupper(path[mplen:])
+
+ return encodingupper(path)
+
def shellquote(s):
if os.sys.platform == 'OpenVMS':
return '"%s"' % s