[PATCH 1 of 4 stable] tag: run commit hook when lock is released (issue3344)
Mads Kiilerich
mads at kiilerich.com
Sat May 12 13:37:43 CDT 2012
# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1336845962 -7200
# Node ID 0802cad1ac04f820ee98ed938df41404dab7258e
# Parent 654b9e1966f76d38b11fbd1d518efce5d58caa88
tag: run commit hook when lock is released (issue3344)
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -904,6 +904,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
@@ -1192,7 +1194,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 --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 @@
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 @@
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
+
More information about the Mercurial-devel
mailing list