# HG changeset patch # User Pierre-Yves David # Date 1595587952 -7200 # Node ID 5d0998ccedbbcc85afd4fa8034e1ccca78484c12 # Parent d056a131c93f282140829315bdd3418526d1cc68 commitctx: stop using weakref proxy for transaction This weakref proxy was introduced in 2007 by 30d4d8985dd8. If I understand it correctly, the logic at that time was relying on the transaction destructor, triggered at garbage collection time to rollback failed transaction. passing the object to sub function directly mean it would live in the function scope and be trapped in the traceback on exception, leading to the transaction rollback too late in some case. Modern transaction usage use explicit opening and closing of transaction and no longer rely on some internal reference counting details. So this weakref proxy is no longer necessary. Absolutely no test are affected when we drop it. diff -r d056a131c93f -r 5d0998ccedbb mercurial/commit.py --- a/mercurial/commit.py Wed Jul 22 16:10:33 2020 +0200 +++ b/mercurial/commit.py Fri Jul 24 12:52:32 2020 +0200 @@ -6,7 +6,6 @@ from __future__ import absolute_import import errno -import weakref from .i18n import _ from .node import ( @@ -62,8 +61,6 @@ p2copies = ctx.p2copies() filesadded, filesremoved = None, None with repo.lock(), repo.transaction(b"commit") as tr: - trp = weakref.proxy(tr) - if ctx.manifestnode(): # reuse an existing manifest revision repo.ui.debug(b'reusing known manifest\n') @@ -102,7 +99,7 @@ else: added.append(f) m[f], is_touched = _filecommit( - repo, fctx, m1, m2, linkrev, trp, writefilecopymeta, + repo, fctx, m1, m2, linkrev, tr, writefilecopymeta, ) if is_touched: touched.append(f) @@ -156,7 +153,7 @@ # case where the merge has files outside of the narrowspec, # so this is safe. mn = mctx.write( - trp, + tr, linkrev, p1.manifestnode(), p2.manifestnode(), @@ -191,7 +188,7 @@ mn, files, ctx.description(), - trp, + tr, p1.node(), p2.node(), user,