amend: disable hooks when creating intermediate commit (issue3501) stable
authorIdan Kamara <idankk86@gmail.com>
Sat, 23 Jun 2012 19:57:29 +0300
branchstable
changeset 17049 2440822446ce
parent 17048 15d4d475de9e
child 17059 fba17a64fa49
child 17079 48f3de605e7b
amend: disable hooks when creating intermediate commit (issue3501)
mercurial/cmdutil.py
tests/test-commit-amend.t
--- a/mercurial/cmdutil.py	Sat Jun 23 19:57:07 2012 +0300
+++ b/mercurial/cmdutil.py	Sat Jun 23 19:57:29 2012 +0300
@@ -1301,7 +1301,11 @@
     try:
         # First, do a regular commit to record all changes in the working
         # directory (if there are any)
-        node = commit(ui, repo, commitfunc, pats, opts)
+        ui.callhooks = False
+        try:
+            node = commit(ui, repo, commitfunc, pats, opts)
+        finally:
+            ui.callhooks = True
         ctx = repo[node]
 
         # Participating changesets:
--- a/tests/test-commit-amend.t	Sat Jun 23 19:57:07 2012 +0300
+++ b/tests/test-commit-amend.t	Sat Jun 23 19:57:29 2012 +0300
@@ -25,11 +25,17 @@
   nothing changed
   [1]
 
+  $ echo '[hooks]' >> $HGRCPATH
+  $ echo 'pretxncommit.foo = echo "pretxncommit $HG_NODE"; hg id -r $HG_NODE' >> $HGRCPATH
+
 Amending changeset with changes in working dir:
 
   $ echo a >> a
   $ hg ci --amend -m 'amend base1'
+  pretxncommit 9cd25b479c51be2f4ed2c38e7abdf7ce67d8e0dc
+  9cd25b479c51 tip
   saved backup bundle to $TESTTMP/.hg/strip-backup/489edb5b847d-amend-backup.hg
+  $ echo 'pretxncommit.foo = ' >> $HGRCPATH
   $ hg diff -c .
   diff -r ad120869acf0 -r 9cd25b479c51 a
   --- a/a	Thu Jan 01 00:00:00 1970 +0000