mercurial/util.py
branchstable
changeset 12877 551aa6e27929
parent 12698 7aef77e74cf3
child 12927 b6245c2470a9
--- a/mercurial/util.py	Fri Oct 29 14:47:45 2010 +0200
+++ b/mercurial/util.py	Fri Oct 29 12:50:08 2010 +0200
@@ -863,9 +863,11 @@
                 nlink = nlinks(f)
             except OSError:
                 nlink = 0
-                d = os.path.dirname(f)
-                if not os.path.isdir(d):
-                    makedirs(d, self.createmode)
+                dirname, basename = os.path.split(f)
+                # Avoid calling makedirs when the path points to a
+                # directory -- the open will raise IOError below.
+                if basename and not os.path.isdir(dirname):
+                    makedirs(dirname, self.createmode)
             if atomictemp:
                 return atomictempfile(f, mode, self.createmode)
             if nlink > 1: