[PATCH] transaction: do not overwrite atomic-temp files on error
Augie Fackler
raf at durin42.com
Thu Jan 3 23:14:59 UTC 2019
queued, thanks
> On Dec 23, 2018, at 1:32 AM, Yuya Nishihara <yuya at tcha.org> wrote:
>
> # HG changeset patch
> # User Yuya Nishihara <yuya at tcha.org>
> # Date 1545536360 -32400
> # Sun Dec 23 12:39:20 2018 +0900
> # Node ID d7abe8f0de4640541bb5717be36e21176733fa40
> # Parent ce0bc2952e2a4061b0961efe11cf7af064c8ea8f
> transaction: do not overwrite atomic-temp files on error
>
> Even though the original files can be restored from the backup, it should be
> better to not write back a temporary file if we know it can be corrupted.
>
> diff --git a/mercurial/transaction.py b/mercurial/transaction.py
> --- a/mercurial/transaction.py
> +++ b/mercurial/transaction.py
> @@ -347,9 +347,13 @@ class transaction(util.transactional):
> files.append(vfs(name, 'w', atomictemp=True,
> checkambig=checkambig))
> genfunc(*files)
> + for f in files:
> + f.close()
> + # skip discard() loop since we're sure no open file remains
> + del files[:]
> finally:
> for f in files:
> - f.close()
> + f.discard()
> return any
>
> @active
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list