# HG changeset patch # User Mads Kiilerich # Date 1336845962 -7200 # Node ID d0e419b0f7de6c63c35979cb18ae7224d3f6182a # Parent 2950d186a9276351142a0aad91c38eccc93b0023 tag: run commit hook when lock is released (issue3344) diff -r 2950d186a927 -r d0e419b0f7de mercurial/localrepo.py --- 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): diff -r 2950d186a927 -r d0e419b0f7de tests/test-hook.t --- 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 diff -r 2950d186a927 -r d0e419b0f7de tests/test-tag.t --- 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 +