makedirs: abort if parent == name (issue2531) stable
authorAdrian Buehlmann <adrian@cadifra.com>
Wed, 01 Dec 2010 21:15:31 +0100
branchstable
changeset 13068 adff480db558
parent 13067 9696954415db
child 13069 6aff4f144ad3
makedirs: abort if parent == name (issue2531) catches unknown drive letters on Windows
mercurial/util.py
--- a/mercurial/util.py	Fri Nov 19 18:07:15 2010 +0900
+++ b/mercurial/util.py	Wed Dec 01 21:15:31 2010 +0100
@@ -833,6 +833,7 @@
 
 def makedirs(name, mode=None):
     """recursive directory creation with parent mode inheritance"""
+    parent = os.path.abspath(os.path.dirname(name))
     try:
         os.mkdir(name)
         if mode is not None:
@@ -841,9 +842,8 @@
     except OSError, err:
         if err.errno == errno.EEXIST:
             return
-        if not name or err.errno != errno.ENOENT:
+        if not name or parent == name or err.errno != errno.ENOENT:
             raise
-    parent = os.path.abspath(os.path.dirname(name))
     makedirs(parent, mode)
     makedirs(name, mode)