# HG changeset patch # User Yuya Nishihara # Date 2018-12-23 03:39:20 # Node ID 3e2c02836420f514c76cecf39a70da79a761e037 # Parent dc56a62735754549c3026c3139a1cc089f21dc52 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