Submitter | Yuya Nishihara |
---|---|
Date | Dec. 23, 2018, 6:32 a.m. |
Message ID | <d7abe8f0de4640541bb5.1545546729@mimosa> |
Download | mbox | patch |
Permalink | /patch/37333/ |
State | Accepted |
Headers | show |
Comments
queued, thanks > On Dec 23, 2018, at 1:32 AM, Yuya Nishihara <yuya@tcha.org> wrote: > > # HG changeset patch > # User Yuya Nishihara <yuya@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@mercurial-scm.org > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Patch
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