changeset 16680:d0e419b0f7de stable

tag: run commit hook when lock is released (issue3344)
author Mads Kiilerich <mads@kiilerich.com>
date Sat, 12 May 2012 20:06:02 +0200
parents 2950d186a927
children 0128cdb846d9
files mercurial/localrepo.py tests/test-hook.t tests/test-tag.t
diffstat 3 files changed, 19 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Sat May 12 20:25:33 2012 +0200
+++ b/mercurial/localrepo.py	Sat May 12 20:06:02 2012 +0200
@@ -920,6 +920,8 @@
         l = self._lockref and self._lockref()
         if l:
             l.postrelease.append(callback)
+        else:
+            callback()
 
     def lock(self, wait=True):
         '''Lock the repository store (.hg/store) and return a weak reference
@@ -1209,7 +1211,9 @@
         finally:
             wlock.release()
 
-        self.hook("commit", node=hex(ret), parent1=hookp1, parent2=hookp2)
+        def commithook(node=hex(ret), parent1=hookp1, parent2=hookp2):
+            self.hook("commit", node=node, parent1=parent1, parent2=parent2)
+        self._afterlock(commithook)
         return ret
 
     def commitctx(self, ctx, error=False):
--- a/tests/test-hook.t	Sat May 12 20:25:33 2012 +0200
+++ b/tests/test-hook.t	Sat May 12 20:06:02 2012 +0200
@@ -101,9 +101,9 @@
   precommit hook: HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2 
   pretxncommit hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PENDING=$TESTTMP/a 
   4:539e4b31b6dc
+  tag hook: HG_LOCAL=0 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_TAG=a 
   commit hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2 
   commit.b hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2 
-  tag hook: HG_LOCAL=0 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_TAG=a 
   $ hg tag -l la
   pretag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=la 
   tag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=la 
--- a/tests/test-tag.t	Sat May 12 20:25:33 2012 +0200
+++ b/tests/test-tag.t	Sat May 12 20:06:02 2012 +0200
@@ -300,3 +300,16 @@
   t3                                 1:c3adabd1a5f4 local
 
   $ cd ..
+
+commit hook on tag used to be run without write lock - issue3344
+
+  $ hg init repo-tag
+  $ hg init repo-tag-target
+  $ hg -R repo-tag --config hooks.commit="hg push \"`pwd`/repo-tag-target\"" tag tag
+  pushing to $TESTTMP/repo-tag-target
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+