[PATCH 2 of 3 🚂] changegroup: use the `postclose` API on transaction
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Fri Nov 7 16:05:29 UTC 2014
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1414507463 -3600
# Tue Oct 28 15:44:23 2014 +0100
# Node ID 27fbb6a1d103c2b4178f859f9010c58601d7042f
# Parent 6c051a14a1aa57c05f2289ab5b82ff6a3098b304
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
@@ -786,13 +786,10 @@ def addchangegroup(repo, source, srctype
# publishing only alter behavior during push
#
# 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
# `destroyed` will repair it.
# In other case we can safely update cache on disk.
@@ -817,11 +814,15 @@ def addchangegroup(repo, source, srctype
newheads = [h for h in repo.heads() if h not in oldheads]
repo.ui.log("incoming",
"%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()
# never return 0 here:
if dh < 0:
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
@@ -460,21 +460,19 @@ Doing the actual push: hook abort
$ hg -R main push other -r e7ec4e813ba6
pushing to other
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]
$ hg -R main push ssh://user@dummy/other -r e7ec4e813ba6
pushing to ssh://user@dummy/other
searching for changes
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
pushing to http://localhost:$HGPORT2/
searching for changes
More information about the Mercurial-devel
mailing list