changeset 3784:1427949b8f80

imported patch folding
author Matt Mackall <mpm@selenic.com>
date Mon, 04 Dec 2006 17:10:29 -0600
parents 4421cef5d3f0
children 6398ff7cb705
files mercurial/util.py
diffstat 1 files changed, 22 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/util.py	Mon Dec 04 14:32:02 2006 -0600
+++ b/mercurial/util.py	Mon Dec 04 17:10:29 2006 -0600
@@ -633,6 +633,28 @@
     except ImportError:
         return None
 
+# File system features
+
+def checkfolding(path):
+    """
+    Check whether the given path is on a case-sensitive filesystem
+
+    Requires a path (like /foo/.hg) ending with a foldable final
+    directory component.
+    """
+    s1 = os.stat(path)
+    d, b = os.path.split(path)
+    p2 = os.path.join(d, b.upper())
+    if path == p2:
+        p2 = os.path.join(d, b.lower())
+    try:
+        s2 = os.stat(p2)
+        if s2 == s1:
+            return False
+        return True
+    except:
+        return True
+
 # Platform specific variants
 if os.name == 'nt':
     demandload(globals(), "msvcrt")