[PATCH 2 of 2 STABLE] amend: disable hooks when creating intermediate commit (issue3501)

Idan Kamara idankk86 at gmail.com
Sat Jun 23 11:58:00 CDT 2012


# HG changeset patch
# User Idan Kamara <idankk86 at gmail.com>
# Date 1340470649 -10800
# Branch stable
# Node ID e3dfdc0b9fe1878a8c98b92ea5eb4d264be589d5
# Parent  26afc4b68fb967ade439d529ac6296faa7cb19c7
amend: disable hooks when creating intermediate commit (issue3501)

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -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:
diff --git a/tests/test-commit-amend.t b/tests/test-commit-amend.t
--- a/tests/test-commit-amend.t
+++ b/tests/test-commit-amend.t
@@ -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


More information about the Mercurial-devel mailing list