# HG changeset patch # User Pierre-Yves David # Date 2014-10-28 14:44:23 # Node ID cadc9a723d602d4b1b843f83b870a1bb543f05aa # Parent 3f543f6be500cbf180b081f417f8d42565ed3ae6 changegroup: use the 'postclose' API on transaction The post-transaction hooks run after the lock release (because hooks may want to touch the repository), but they must only run if the transaction is successfully closed. We use the new 'addpostclose' method on transaction to register a callback installing this post-lock-release call. diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py --- a/mercurial/changegroup.py +++ b/mercurial/changegroup.py @@ -788,9 +788,6 @@ def addchangegroup(repo, source, srctype # strip should not touch boundary at all phases.retractboundary(repo, tr, targetphase, added) - - tr.close() - if changesets > 0: if srctype != 'strip': # During strip, branchcache is invalid but coming call to @@ -819,7 +816,11 @@ def addchangegroup(repo, source, srctype "%s incoming changes - new heads: %s\n", len(added), ', '.join([hex(c[:6]) for c in newheads])) - repo._afterlock(runhooks) + + tr.addpostclose('changegroup-runhooks-%020i' % clstart, + lambda: repo._afterlock(runhooks)) + + tr.close() finally: tr.release() diff --git a/tests/test-bundle2-exchange.t b/tests/test-bundle2-exchange.t --- a/tests/test-bundle2-exchange.t +++ b/tests/test-bundle2-exchange.t @@ -462,7 +462,6 @@ Doing the actual push: hook abort searching for changes transaction abort! rollback completed - changegroup hook: HG_BUNDLE2-EXP=1 HG_NODE=e7ec4e813ba6b07be2a0516ce1a74bb4e503f91a HG_SOURCE=push HG_URL=push abort: b2x-pretransactionclose.failpush hook exited with status 1 [255] @@ -472,7 +471,6 @@ Doing the actual push: hook abort abort: b2x-pretransactionclose.failpush hook exited with status 1 remote: transaction abort! remote: rollback completed - remote: changegroup hook: HG_BUNDLE2-EXP=1 HG_NODE=e7ec4e813ba6b07be2a0516ce1a74bb4e503f91a HG_SOURCE=serve HG_URL=remote:ssh:127.0.0.1 [255] $ hg -R main push http://localhost:$HGPORT2/ -r e7ec4e813ba6