# HG changeset patch # User Joerg Sonnenberger # Date 2020-04-30 23:32:08 # Node ID 09da5cf447728a7605bc3b2990797ad35b2bcad2 # Parent be6401a2572646712aebe80520ee8909562bb0a5 hooks: provide access to transaction changes for internal hooks External hooks are skipped here as the environment often has a size limit in the low MBs and that can easily be reached by larger transactions. Differential Revision: https://phab.mercurial-scm.org/D8490 diff --git a/mercurial/hook.py b/mercurial/hook.py --- a/mercurial/hook.py +++ b/mercurial/hook.py @@ -158,6 +158,10 @@ def _exthook(ui, repo, htype, name, cmd, env[b'HG_HOOKNAME'] = name for k, v in pycompat.iteritems(args): + # transaction changes can accumulate MBs of data, so skip it + # for external hooks + if k == b'changes': + continue if callable(v): v = v() if isinstance(v, (dict, list)): diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -2243,6 +2243,7 @@ class localrepository(object): tr.hookargs[b'txnid'] = txnid tr.hookargs[b'txnname'] = desc + tr.hookargs[b'changes'] = tr.changes # note: writing the fncache only during finalize mean that the file is # outdated when running hooks. As fncache is used for streaming clone, # this is not expected to break anything that happen during the hooks. diff --git a/tests/test-hook.t b/tests/test-hook.t --- a/tests/test-hook.t +++ b/tests/test-hook.t @@ -443,7 +443,7 @@ more there after HG_PENDING=$TESTTMP/a transaction abort! - txnabort Python hook: txnid,txnname + txnabort Python hook: changes,txnid,txnname txnabort hook: HG_HOOKNAME=txnabort.1 HG_HOOKTYPE=txnabort HG_TXNID=TXN:$ID$