diff mercurial/changegroup.py @ 23221:cadc9a723d60

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.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Tue, 28 Oct 2014 15:44:23 +0100
parents 2d54aa5397cd
children c58432685cff
line wrap: on
line diff
--- 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()