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.
--- a/mercurial/changegroup.py Tue Oct 28 14:24:43 2014 +0100
+++ b/mercurial/changegroup.py Tue Oct 28 15:44:23 2014 +0100
@@ -788,9 +788,6 @@
# 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 @@
"%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()
--- a/tests/test-bundle2-exchange.t Tue Oct 28 14:24:43 2014 +0100
+++ b/tests/test-bundle2-exchange.t Tue Oct 28 15:44:23 2014 +0100
@@ -462,7 +462,6 @@
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 @@
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