[PATCH 06 of 11] util: introduce foldedpath which returns one writing for folded paths

Simon Heimberg simohe at besonet.ch
Fri Aug 7 14:43:04 CDT 2009


# HG changeset patch
# User Simon Heimberg <simohe at besonet.ch>
# Date 1249671871 -7200
# Node ID 4ca92bfc595d6c55e3a93b77b4fb33250ec41382
# Parent  50e9f6b4d8878fd867a250c5be2578330b7f4769
util: introduce foldedpath which returns one writing for folded paths

The description is the goal, not fully reached.
Not the same as realpath, the later returns the current path on disc

overwrite with better alternatives in posix

diff -r 50e9f6b4d887 -r 4ca92bfc595d mercurial/posix.py
--- a/mercurial/posix.py	Fre Aug 07 16:56:35 2009 +0200
+++ b/mercurial/posix.py	Fre Aug 07 21:04:31 2009 +0200
@@ -139,6 +139,13 @@
         finally:
             os.close(fd)
 
+    def foldedpath(path):
+        return realpath(path, None).lower()
+else:
+    def foldedpath(path):
+        # do lower for caseinsensitive filesystems
+        return os.path.normpath(path).lower()
+
 def shellquote(s):
     if os.sys.platform == 'OpenVMS':
         return '"%s"' % s
diff -r 50e9f6b4d887 -r 4ca92bfc595d mercurial/util.py
--- a/mercurial/util.py	Fre Aug 07 16:56:35 2009 +0200
+++ b/mercurial/util.py	Fre Aug 07 21:04:31 2009 +0200
@@ -582,6 +582,13 @@
     '''
     return fspath(path, root)
 
+def foldedpath(path):
+    '''
+    Returns the same path for all possible folded path names on
+    caseinsensitive filesystems
+    '''
+    return os.path.normcase(os.path.normpath(path))
+
 if os.name == 'nt':
     from windows import *
 else:


More information about the Mercurial-devel mailing list