audit: check for casefolding of .hg (issue1450)
authorMatt Mackall <mpm@selenic.com>
Mon, 16 Feb 2009 17:37:23 -0600
changeset 7784 8a217626bb0c
parent 7783 2c5b2abfb8be
child 7785 660c8dd44060
audit: check for casefolding of .hg (issue1450)
mercurial/util.py
--- a/mercurial/util.py	Mon Feb 16 17:37:23 2009 -0600
+++ b/mercurial/util.py	Mon Feb 16 17:37:23 2009 -0600
@@ -815,13 +815,15 @@
             return
         normpath = os.path.normcase(path)
         parts = splitpath(normpath)
-        if (os.path.splitdrive(path)[0] or parts[0] in ('.hg', '.hg.', '')
+        if (os.path.splitdrive(path)[0]
+            or parts[0].lower() in ('.hg', '.hg.', '')
             or os.pardir in parts):
             raise Abort(_("path contains illegal component: %s") % path)
-        if '.hg' in path:
+        if '.hg' in path.lower():
+            lparts = [p.lower() for p in parts]
             for p in '.hg', '.hg.':
-                if p in parts[1:-1]:
-                    pos = parts.index(p)
+                if p in lparts[1:-1]:
+                    pos = lparts.index(p)
                     base = os.path.join(*parts[:pos])
                     raise Abort(_('path %r is inside repo %r') % (path, base))
         def check(prefix):