Mercurial > hg
changeset 12877:551aa6e27929 stable
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.
author | Martin Geisler <mg@aragost.com> |
---|---|
date | Fri, 29 Oct 2010 12:50:08 +0200 |
parents | a3b182dd548a |
children | 1634287b6ab1 |
files | mercurial/util.py |
diffstat | 1 files changed, 5 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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: