[PATCH 09 of 13 STABLE V4] icasefs: avoid path-absoluteness/existance check in util.fspath() for efficiency

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Fri Dec 16 06:27:17 CST 2011


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1324037380 -32400
# Branch stable
# Node ID 0ff8a29782b7b8d85f8dcd4a74d4b8a36773ecb6
# Parent  8608f1f307974f619ce6b0342592daf7cfee5754
icasefs: avoid path-absoluteness/existance check in util.fspath() for efficiency

'dirstate._normalize()', the only caller of 'util.fspath()', has
already confirmed exsistance of specified file as relative to root.

so, this patch omits path-absoluteness/existance check from
'util.fspath()'.

diff -r 8608f1f30797 -r 0ff8a29782b7 mercurial/util.py
--- a/mercurial/util.py	Fri Dec 16 21:09:40 2011 +0900
+++ b/mercurial/util.py	Fri Dec 16 21:09:40 2011 +0900
@@ -613,22 +613,13 @@
 def fspath(name, root):
     '''Get name in the case stored in the filesystem
 
-    The name is either relative to root, or it is an absolute path starting
-    with root. Note that this function is unnecessary, and should not be
+    The name should be relative to root, and be normcase-ed for efficiency.
+
+    Note that this function is unnecessary, and should not be
     called, for case-sensitive filesystems (simply because it's expensive).
 
-    Both name and root should be normcase-ed.
+    The root should be normcase-ed, too.
     '''
-    # If name is absolute, make it relative
-    if name.startswith(root):
-        l = len(root)
-        if name[l] == os.sep or name[l] == os.altsep:
-            l = l + 1
-        name = name[l:]
-
-    if not os.path.lexists(os.path.join(root, name)):
-        return None
-
     def find(p, contents):
         lenp = len(p)
         for n in contents:


More information about the Mercurial-devel mailing list