opener: do not create "foo" directory when writing to "foo/"
The directories were not cleaned up when the subsequent open failed
and this would confuse things like qnew.
--- 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: