Mercurial > public > mercurial-scm > hg
comparison mercurial/util.py @ 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 | 7aef77e74cf3 |
children | b6245c2470a9 |
comparison
equal
deleted
inserted
replaced
12876:a3b182dd548a | 12877:551aa6e27929 |
---|---|
861 if mode not in ("r", "rb"): | 861 if mode not in ("r", "rb"): |
862 try: | 862 try: |
863 nlink = nlinks(f) | 863 nlink = nlinks(f) |
864 except OSError: | 864 except OSError: |
865 nlink = 0 | 865 nlink = 0 |
866 d = os.path.dirname(f) | 866 dirname, basename = os.path.split(f) |
867 if not os.path.isdir(d): | 867 # Avoid calling makedirs when the path points to a |
868 makedirs(d, self.createmode) | 868 # directory -- the open will raise IOError below. |
869 if basename and not os.path.isdir(dirname): | |
870 makedirs(dirname, self.createmode) | |
869 if atomictemp: | 871 if atomictemp: |
870 return atomictempfile(f, mode, self.createmode) | 872 return atomictempfile(f, mode, self.createmode) |
871 if nlink > 1: | 873 if nlink > 1: |
872 rename(mktempcopy(f), f) | 874 rename(mktempcopy(f), f) |
873 fp = posixfile(f, mode) | 875 fp = posixfile(f, mode) |