Patchwork [5,of,8] import: change "editform" to distinguish merge commits from other (--bypass)

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Aug. 15, 2014, 2:09 p.m.
Message ID <5dec3e408ac2ac085b40.1408111763@feefifofum>
Download mbox | patch
Permalink /patch/5420/
State Accepted
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 5dec3e408ac2ac085b4060534a216b42be3d6726
# Parent  9013cc6a4679944690a6914ac64407ff7ce0f0a2
import: change "editform" to distinguish merge commits from other (--bypass)

"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 "bypass.normal" and "bypass.merge" as ROUTE of
"editform" instead of "bypass", to distinguish merge commits from
other in "hg import --bypass" case.

Unlike other patches in this series, this patch uses "editor.sh"
instead of "checkeditform.sh" for the name of the script to check
"HGEDITFORM", because it has to do more than checking "HGEDITFORM".

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -691,7 +691,11 @@ 
                                     files, eolmode=None)
                 except patch.PatchError, e:
                     raise util.Abort(str(e))
-                editor = getcommiteditor(editform='import.bypass')
+                if p2.node() != nullid:
+                    editform = 'import.bypass.merge'
+                else:
+                    editform = 'import.bypass.normal'
+                editor = getcommiteditor(editform=editform)
                 memctx = context.makememctx(repo, (p1.node(), p2.node()),
                                             message,
                                             opts.get('user') or user,
diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
--- a/mercurial/help/config.txt
+++ b/mercurial/help/config.txt
@@ -405,7 +405,8 @@ 
 - ``changeset.histedit.fold`` for ``fold`` of :hg:`histedit`
 - ``changeset.histedit.mess`` for ``mess`` of :hg:`histedit`
 - ``changeset.histedit.pick`` for ``pick`` of :hg:`histedit`
-- ``changeset.import.bypass`` for :hg:`import --bypass`
+- ``changeset.import.bypass.merge`` for :hg:`import --bypass` on merges
+- ``changeset.import.bypass.normal`` for :hg:`import --bypass` on other
 - ``changeset.import.normal.merge`` for :hg:`import` on merges
 - ``changeset.import.normal.normal`` for :hg:`import` on other
 - ``changeset.mq.qnew`` for :hg:`qnew`
diff --git a/tests/test-import-bypass.t b/tests/test-import-bypass.t
--- a/tests/test-import-bypass.t
+++ b/tests/test-import-bypass.t
@@ -121,8 +121,13 @@ 
   > +b
   > +c
   > EOF
-  $ HGEDITOR=cat hg import --bypass ../test.diff
-  applying ../test.diff
+  $ cat > $TESTTMP/editor.sh <<EOF
+  > env | grep HGEDITFORM
+  > cat \$1
+  > EOF
+  $ HGEDITOR="sh $TESTTMP/editor.sh" hg import --bypass ../test.diff
+  applying ../test.diff
+  HGEDITFORM=import.bypass.normal
   
   
   HG: Enter commit message.  Lines beginning with 'HG:' are removed.
diff --git a/tests/test-import-merge.t b/tests/test-import-merge.t
--- a/tests/test-import-merge.t
+++ b/tests/test-import-merge.t
@@ -92,8 +92,9 @@ 
 
   $ hg up 1
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ hg import --bypass ../merge.diff
-  applying ../merge.diff
+  $ HGEDITOR="sh $TESTTMP/editor.sh" hg import --bypass -e ../merge.nomsg.diff
+  applying ../merge.nomsg.diff
+  HGEDITFORM=import.bypass.merge
   $ tipparents
   1:540395c44225 changea
   3:102a90ea7b4a addb