[PATCH 2 of 3] util.makedirs: make recursion simpler and more stable (issue2948)

Adrian Buehlmann adrian at cadifra.com
Mon Aug 22 02:10:47 CDT 2011


On 2011-08-22 01:07, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich <mads at kiilerich.com>
> # Date 1313966558 -7200
> # Branch stable
> # Node ID 4191b702114a9bb2b6287ce622060589763ac038
> # Parent  b2881a5ceecc79052c48103eeb04d3d4d02ee3ee
> 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.
> 
> diff --git a/mercurial/util.py b/mercurial/util.py
> --- a/mercurial/util.py
> +++ b/mercurial/util.py
> @@ -766,7 +766,7 @@
>          if not name or parent == name or err.errno != errno.ENOENT:
>              raise
>          makedirs(parent, mode)
> -        makedirs(name, mode)
> +        os.mkdir(name)
>      if mode is not None:
>          os.chmod(name, mode)

+1
Ageed.



More information about the Mercurial-devel mailing list