comparison mercurial/util.py @ 7784:8a217626bb0c

audit: check for casefolding of .hg (issue1450)
author Matt Mackall <mpm@selenic.com>
date Mon, 16 Feb 2009 17:37:23 -0600
parents 9892c4d94fb7
children 346fafc144fc
comparison
equal deleted inserted replaced
7783:2c5b2abfb8be 7784:8a217626bb0c
813 def __call__(self, path): 813 def __call__(self, path):
814 if path in self.audited: 814 if path in self.audited:
815 return 815 return
816 normpath = os.path.normcase(path) 816 normpath = os.path.normcase(path)
817 parts = splitpath(normpath) 817 parts = splitpath(normpath)
818 if (os.path.splitdrive(path)[0] or parts[0] in ('.hg', '.hg.', '') 818 if (os.path.splitdrive(path)[0]
819 or parts[0].lower() in ('.hg', '.hg.', '')
819 or os.pardir in parts): 820 or os.pardir in parts):
820 raise Abort(_("path contains illegal component: %s") % path) 821 raise Abort(_("path contains illegal component: %s") % path)
821 if '.hg' in path: 822 if '.hg' in path.lower():
823 lparts = [p.lower() for p in parts]
822 for p in '.hg', '.hg.': 824 for p in '.hg', '.hg.':
823 if p in parts[1:-1]: 825 if p in lparts[1:-1]:
824 pos = parts.index(p) 826 pos = lparts.index(p)
825 base = os.path.join(*parts[:pos]) 827 base = os.path.join(*parts[:pos])
826 raise Abort(_('path %r is inside repo %r') % (path, base)) 828 raise Abort(_('path %r is inside repo %r') % (path, base))
827 def check(prefix): 829 def check(prefix):
828 curpath = os.path.join(self.root, prefix) 830 curpath = os.path.join(self.root, prefix)
829 try: 831 try: