changeset 15669:390bcd01775a stable

icasefs: use util.normcase() instead of lower() or os.path.normcase in fspath this also avoids lower()-ing on each path components by reuse the path normcase()-ed at beginning of function.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Fri, 16 Dec 2011 21:09:40 +0900
parents 8e020155e76c
children d6c19cfa03ce
files mercurial/util.py
diffstat 1 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/util.py	Fri Dec 16 21:09:40 2011 +0900
+++ b/mercurial/util.py	Fri Dec 16 21:09:40 2011 +0900
@@ -618,7 +618,9 @@
     called, for case-sensitive filesystems (simply because it's expensive).
     '''
     # If name is absolute, make it relative
-    if name.lower().startswith(root.lower()):
+    name = normcase(name)
+    root = normcase(root)
+    if name.startswith(root):
         l = len(root)
         if name[l] == os.sep or name[l] == os.altsep:
             l = l + 1
@@ -633,7 +635,7 @@
     # Protect backslashes. This gets silly very quickly.
     seps.replace('\\','\\\\')
     pattern = re.compile(r'([^%s]+)|([%s]+)' % (seps, seps))
-    dir = os.path.normcase(os.path.normpath(root))
+    dir = os.path.normpath(root)
     result = []
     for part, sep in pattern.findall(name):
         if sep:
@@ -644,16 +646,15 @@
             _fspathcache[dir] = os.listdir(dir)
         contents = _fspathcache[dir]
 
-        lpart = part.lower()
         lenp = len(part)
         for n in contents:
-            if lenp == len(n) and n.lower() == lpart:
+            if lenp == len(n) and normcase(n) == part:
                 result.append(n)
                 break
         else:
             # Cannot happen, as the file exists!
             result.append(part)
-        dir = os.path.join(dir, lpart)
+        dir = os.path.join(dir, part)
 
     return ''.join(result)