makedirs: abort if parent == name (issue2531)
catches unknown drive letters on Windows
--- 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)