--- a/mercurial/pathutil.py Wed Dec 17 15:11:26 2014 -0800
+++ b/mercurial/pathutil.py Thu Dec 18 16:41:59 2014 -0600
@@ -1,8 +1,12 @@
import os, errno, stat
+import encoding
import util
from i18n import _
+def _lowerclean(s):
+ return encoding.hfsignoreclean(s.lower())
+
class pathauditor(object):
'''ensure that a filesystem path contains no banned components.
the following properties of a path are checked:
@@ -39,11 +43,18 @@
raise util.Abort(_("path ends in directory separator: %s") % path)
parts = util.splitpath(path)
if (os.path.splitdrive(path)[0]
- or parts[0].lower() in ('.hg', '.hg.', '')
+ or _lowerclean(parts[0]) in ('.hg', '.hg.', '')
or os.pardir in parts):
raise util.Abort(_("path contains illegal component: %s") % path)
- if '.hg' in path.lower():
- lparts = [p.lower() for p in parts]
+ # Windows shortname aliases
+ for p in parts:
+ if "~" in p:
+ first, last = p.split("~", 1)
+ if last.isdigit() and first.upper() in ["HG", "HG8B6C"]:
+ raise util.Abort(_("path contains illegal component: %s")
+ % path)
+ if '.hg' in _lowerclean(path):
+ lparts = [_lowerclean(p.lower()) for p in parts]
for p in '.hg', '.hg.':
if p in lparts[1:]:
pos = lparts.index(p)