util.makedirs: propagate chmod exceptions
The existing exception handling was intended to handle mkdir errors. Strange
chmod exceptions could thus have strange consequences - or be swallowed.
--- a/mercurial/util.py Sun Aug 21 20:40:10 2011 +0100
+++ b/mercurial/util.py Mon Aug 22 00:35:42 2011 +0200
@@ -783,16 +783,15 @@
parent = os.path.abspath(os.path.dirname(name))
try:
os.mkdir(name)
- if mode is not None:
- os.chmod(name, mode)
- return
except OSError, err:
if err.errno == errno.EEXIST:
return
if not name or parent == name or err.errno != errno.ENOENT:
raise
- makedirs(parent, mode)
- makedirs(name, mode)
+ makedirs(parent, mode)
+ makedirs(name, mode)
+ if mode is not None:
+ os.chmod(name, mode)
def readfile(path):
fp = open(path, 'rb')