comparison mercurial/util.py @ 15050:ff3e93686306

util.makedirs: make recursion simpler and more stable (issue2948) Before, makedirs could call itself recursively with the same path name it was given, relying on sane file system behavior to terminate the recursion. That could cause infinite recursion on insane file systems. Instead we now call mkdir explicitly after having created parent directory recursively. Exceptions from this mkdir is not swallowed.
author Mads Kiilerich <mads@kiilerich.com>
date Mon, 22 Aug 2011 00:42:38 +0200
parents 79a861b8f553
children 774da7121fc9
comparison
equal deleted inserted replaced
15049:79a861b8f553 15050:ff3e93686306
787 if err.errno == errno.EEXIST: 787 if err.errno == errno.EEXIST:
788 return 788 return
789 if not name or parent == name or err.errno != errno.ENOENT: 789 if not name or parent == name or err.errno != errno.ENOENT:
790 raise 790 raise
791 makedirs(parent, mode) 791 makedirs(parent, mode)
792 makedirs(name, mode) 792 os.mkdir(name)
793 if mode is not None: 793 if mode is not None:
794 os.chmod(name, mode) 794 os.chmod(name, mode)
795 795
796 def readfile(path): 796 def readfile(path):
797 fp = open(path, 'rb') 797 fp = open(path, 'rb')