Patchwork [3,of,8] commit: change "editform" to distinguish merge commits from other (--amend)

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Aug. 15, 2014, 2:09 p.m.
Message ID <4bc6e8328f55eb0f982d.1408111761@feefifofum>
Download mbox | patch
Permalink /patch/5417/
State Superseded
Commit f5ff18f65b73d9ba3b2847b4e1b874d23f08cb9f
Headers show

Comments

Katsunori FUJIWARA - Aug. 15, 2014, 2:09 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1408111553 -32400
#      Fri Aug 15 23:05:53 2014 +0900
# Node ID 4bc6e8328f55eb0f982d2f9ad4fe669e42780897
# Parent  aee1879e03e5ef361a648cd98804cc635f21e274
commit: change "editform" to distinguish merge commits from other (--amend)

"editform" argument for "getcommiteditor" is decided according to the
format below:

  COMMAND[.ROUTE]

  - COMMAND: name of command
  - ROUTE: name of route, if there are two or more routes in COMMAND

This patch uses "amend.normal" and "amend.merge" as ROUTE of
"editform" instead of "amend", to distinguish merge commits from other
in "hg commit --amend" case.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2114,7 +2114,10 @@ 
 
                 user = opts.get('user') or old.user()
                 date = opts.get('date') or old.date()
-            editform = 'commit.amend'
+            if 1 < len(old.parents()):
+                editform = 'commit.amend.merge'
+            else:
+                editform = 'commit.amend.normal'
             editor = getcommiteditor(editform=editform, **opts)
             if not message:
                 editor = getcommiteditor(edit=True, editform=editform)
diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
--- a/mercurial/help/config.txt
+++ b/mercurial/help/config.txt
@@ -394,7 +394,8 @@ 
 messages for each actions.
 
 - ``changeset.backout`` for :hg:`backout`
-- ``changeset.commit.amend`` for :hg:`commit --amend`
+- ``changeset.commit.amend.merge`` for :hg:`commit --amend` on merges
+- ``changeset.commit.amend.normal`` for :hg:`commit --amend` on other
 - ``changeset.commit.normal.merge`` for :hg:`commit` on merges
 - ``changeset.commit.normal.normal`` for :hg:`commit` on other
 - ``changeset.fetch`` for :hg:`fetch` (impling merge commit)
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
@@ -145,7 +145,12 @@ 
 
 Test -u/-d:
 
-  $ hg ci --amend -u foo -d '1 0'
+  $ cat > .hg/checkeditform.sh <<EOF
+  > env | grep HGEDITFORM
+  > true
+  > EOF
+  $ HGEDITOR="sh .hg/checkeditform.sh" hg ci --amend -u foo -d '1 0'
+  HGEDITFORM=commit.amend.normal
   saved backup bundle to $TESTTMP/.hg/strip-backup/1cd866679df8-amend-backup.hg (glob)
   $ echo a >> a
   $ hg ci --amend -u foo -d '1 0'
@@ -619,7 +624,8 @@ 
   zz renamed from z:69a1b67522704ec122181c0890bd16e9d3e7516a
   $ hg debugrename cc
   cc not renamed
-  $ hg ci --amend -m 'merge bar (amend message)'
+  $ HGEDITOR="sh .hg/checkeditform.sh" hg ci --amend -m 'merge bar (amend message)' --edit
+  HGEDITFORM=commit.amend.merge
   $ hg log --config diff.git=1 -pr .
   changeset:   24:832b50f2c271
   tag:         tip