[PATCH 1 of 3] util.makedirs: propagate chmod exceptions
Mads Kiilerich
mads at kiilerich.com
Sun Aug 21 18:07:43 CDT 2011
# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1313966142 -7200
# Branch stable
# Node ID b2881a5ceecc79052c48103eeb04d3d4d02ee3ee
# Parent 7f504202cb5c62e37d07441180ebc866b8ea02b8
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.
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -760,16 +760,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')
More information about the Mercurial-devel
mailing list