# HG changeset patch # User Pierre-Yves David <pierre-yves.da...@octobus.net> # Date 1595587952 -7200 # Fri Jul 24 12:52:32 2020 +0200 # Node ID 76a585b26acdaf884e1c40252e351b1d45cbbcf1 # Parent 2727e91ffa6e9063bd9c29671b5008cfef22dd97 # EXP-Topic commitctx-cleanup-2 # Available At https://foss.heptapod.net/octobus/mercurial-devel/ # hg pull https://foss.heptapod.net/octobus/mercurial-devel/ -r 76a585b26acd 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 --git a/mercurial/commit.py b/mercurial/commit.py --- a/mercurial/commit.py +++ b/mercurial/commit.py @@ -6,7 +6,6 @@ from __future__ import absolute_import import errno -import weakref from .i18n import _ from .node import ( @@ -62,8 +61,6 @@ def commitctx(repo, ctx, error=False, or 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 @@ def commitctx(repo, ctx, error=False, or 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 @@ def commitctx(repo, ctx, error=False, or # 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 @@ def commitctx(repo, ctx, error=False, or mn, files, ctx.description(), - trp, + tr, p1.node(), p2.node(), user, _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel