# HG changeset patch # User Matt Mackall # Date 1165273829 21600 # Node ID 1427949b8f809c7c5b39c1ca5839390ec1c9bce6 # Parent 4421cef5d3f0c152340e0dcb89be3b24cb706561 imported patch folding diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -633,6 +633,28 @@ def groupname(gid=None): 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")