# HG changeset patch # User Mads Kiilerich # Date 2011-08-21 22:35:42 # Node ID 79a861b8f55346f773fa0e96888e655eea966c86 # Parent 2f0a3977c9390cef8bbad69ecab4d3e20a9682b8 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 @@ -783,16 +783,15 @@ def makedirs(name, mode=None): 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')