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