Make a few portability improvements to path auditing code.
authorBryan O'Sullivan <bos@serpentine.com>
Fri, 10 Aug 2007 10:51:47 -0700
changeset 5159 d84329a11fdd
parent 5158 d316124ebbea
child 5160 a04694e08775
Make a few portability improvements to path auditing code.
mercurial/util.py
--- a/mercurial/util.py	Fri Aug 10 10:46:03 2007 -0700
+++ b/mercurial/util.py	Fri Aug 10 10:51:47 2007 -0700
@@ -698,7 +698,8 @@
     def __call__(self, path):
         if path in self.audited:
             return
-        parts = os.path.normcase(path).split(os.sep)
+        normpath = os.path.normcase(path)
+        parts = normpath.split(os.sep)
         if (os.path.splitdrive(path)[0] or parts[0] in ('.hg', '')
             or os.pardir in parts):
             raise Abort(_("path contains illegal component: %s") % path)
@@ -713,12 +714,13 @@
                 if stat.S_ISLNK(st.st_mode):
                     raise Abort(_('path %r traverses symbolic link %r') %
                                 (path, prefix))
-                if os.path.exists(os.path.join(curpath, '.hg')):
+                elif (stat.S_ISDIR(st.st_mode) and
+                      os.path.isdir(os.path.join(curpath, '.hg'))):
                     raise Abort(_('path %r is inside repo %r') %
                                 (path, prefix))
             self.audited[prefix] = True
-        for c in strutil.rfindall(path, os.sep):
-            check(path[:c])
+        for c in strutil.rfindall(normpath, os.sep):
+            check(normpath[:c])
         self.audited[path] = True
 
 def _makelock_file(info, pathname):