changeset 15049:79a861b8f553

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.
author Mads Kiilerich <mads@kiilerich.com>
date Mon, 22 Aug 2011 00:35:42 +0200
parents 2f0a3977c939
children ff3e93686306
files mercurial/util.py
diffstat 1 files changed, 4 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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')