pushkey: run hook after the lock release
authorPierre-Yves David <pierre-yves.david@fb.com>
Mon, 22 Dec 2014 15:48:39 -0800
changeset 23648 915ac9403e13
parent 23647 eb55e09202c8
child 23649 18ab5e5955df
pushkey: run hook after the lock release The pushkey operation used to be in its own wireprotocol command and (in practice) always be lock free when running the hook. With bundle2, it happen in a greater scheme and a hook running locking command would get stuck. We now run such hooks after the lock release as similar hook do. Bundle2 test are altered to ensure we are lockfree at hook running time.
mercurial/localrepo.py
tests/test-bundle2-exchange.t
--- a/mercurial/localrepo.py	Fri Dec 12 15:31:28 2014 -0800
+++ b/mercurial/localrepo.py	Mon Dec 22 15:48:39 2014 -0800
@@ -1785,8 +1785,10 @@
             return False
         self.ui.debug('pushing key for "%s:%s"\n' % (namespace, key))
         ret = pushkey.push(self, namespace, key, old, new)
-        self.hook('pushkey', namespace=namespace, key=key, old=old, new=new,
-                  ret=ret)
+        def runhook():
+            self.hook('pushkey', namespace=namespace, key=key, old=old, new=new,
+                      ret=ret)
+        self._afterlock(runhook)
         return ret
 
     def listkeys(self, namespace):
--- a/tests/test-bundle2-exchange.t	Fri Dec 12 15:31:28 2014 -0800
+++ b/tests/test-bundle2-exchange.t	Mon Dec 22 15:48:39 2014 -0800
@@ -24,6 +24,7 @@
   > b2x-pretransactionclose.tip = hg log -r tip -T "pre-close-tip:{node|short} {phase} {bookmarks}\n"
   > b2x-transactionclose.tip = hg log -r tip -T "postclose-tip:{node|short} {phase} {bookmarks}\n"
   > b2x-transactionclose.env = sh -c  "HG_LOCAL= python \"$TESTDIR/printenv.py\" b2x-transactionclose"
+  > pushkey= echo pushkey: lock state after \"\$HG_NAMESPACE\"; hg debuglock
   > EOF
 
 The extension requires a repo (currently unused)
@@ -167,6 +168,12 @@
   pushing to other
   searching for changes
   pre-close-tip:eea13746799a public book_eea1
+  pushkey: lock state after "phases"
+  lock:  free
+  wlock: free
+  pushkey: lock state after "bookmarks"
+  lock:  free
+  wlock: free
   postclose-tip:eea13746799a public book_eea1
   b2x-transactionclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2-EXP=1 HG_NEW_OBSMARKERS=1 HG_NODE=eea13746799a9e0bfd88f29d3c2e9dc9389f524f HG_PHASES_MOVED=1 HG_SOURCE=push HG_URL=push
   changegroup hook: HG_BUNDLE2-EXP=1 HG_NODE=eea13746799a9e0bfd88f29d3c2e9dc9389f524f HG_SOURCE=push HG_URL=push
@@ -254,6 +261,9 @@
   remote: 1 new obsolescence markers
   updating bookmark book_5fdd
   remote: pre-close-tip:5fddd98957c8 draft book_5fdd
+  remote: pushkey: lock state after "bookmarks"
+  remote: lock:  free
+  remote: wlock: free
   remote: postclose-tip:5fddd98957c8 draft book_5fdd
   remote: b2x-transactionclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2-EXP=1 HG_NEW_OBSMARKERS=1 HG_NODE=5fddd98957c8a54a4d436dfe1da9d87f21a1b97b HG_SOURCE=serve HG_URL=remote:ssh:127.0.0.1
   remote: changegroup hook: HG_BUNDLE2-EXP=1 HG_NODE=5fddd98957c8a54a4d436dfe1da9d87f21a1b97b HG_SOURCE=serve HG_URL=remote:ssh:127.0.0.1