diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -920,6 +920,8 @@ class localrepository(repo.repository): 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 @@ class localrepository(repo.repository): 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 --git a/tests/test-hook.t b/tests/test-hook.t --- a/tests/test-hook.t +++ b/tests/test-hook.t @@ -101,9 +101,9 @@ tag hooks can see env vars 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 --git a/tests/test-tag.t b/tests/test-tag.t --- a/tests/test-tag.t +++ b/tests/test-tag.t @@ -300,3 +300,16 @@ tagging on an uncommitted merge (issue25 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 +