[PATCH 1 of 2] util: checknlink should remove file it creates if an exception occurs

Yuya Nishihara yuya at tcha.org
Wed Aug 24 08:15:16 EDT 2016


On Fri, 19 Aug 2016 13:58:39 -0700, ttung at fb.com wrote:
> # HG changeset patch
> # User Tony Tung <tonytung at merly.org>
> # Date 1471638640 25200
> #      Fri Aug 19 13:30:40 2016 -0700
> # Node ID 2efc5a05d80a6d4253767f2ce0c2fb062ba83cb6
> # Parent  9d02bed8477bec7f679d6aeb5b1dd8bcdb80f64d
> util: checknlink should remove file it creates if an exception occurs
> 
> There's no reason to leave the file behind.
> 
> diff --git a/mercurial/util.py b/mercurial/util.py
> --- a/mercurial/util.py
> +++ b/mercurial/util.py
> @@ -1313,6 +1313,10 @@
>      try:
>          posixfile(f1, 'w').close()
>      except IOError:
> +        try:
> +            os.unlink(f1)
> +        except OSError:
> +            pass
>          return False

I've taken only this from er V0, thanks.


More information about the Mercurial-devel mailing list