[PATCH 4 of 6 V2] import: change "editform" to distinguish merge commits from other (--bypass)

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Fri Aug 15 20:58:14 CDT 2014


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1408153439 -32400
#      Sat Aug 16 10:43:59 2014 +0900
# Node ID 0bd52dd2d4e898e53157f85a57a57c2369f82e98
# Parent  8625b27c3863a8b9af215b96bce59087c319d340
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.

This patch passes bool as "ctxorbool" to "mergeeditform", because the
context to be committed should be created after getting editor.

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".

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -705,7 +705,8 @@
                                     files, eolmode=None)
                 except patch.PatchError, e:
                     raise util.Abort(str(e))
-                editor = getcommiteditor(editform='import.bypass')
+                editform = mergeeditform(p2.node() != nullid, 'import.bypass')
+                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


More information about the Mercurial-devel mailing list