changeset 22250:f3200bf460a8

import: change "editform" to distinguish merge commits from others "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 "normal.normal" and "normal.merge" as ROUTE of "editform" instead of "normal", to distinguish merge commits from other in "hg import" without "--bypass" case. This patch assumes "editform" variations for "hg import" below: import.normal.normal import.normal.merge import.bypass.normal import.bypass.merge 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". To invoke editor forcibly in "test-import-merge.t", this patch creates the patch not having patch description as "merge.nomsg.diff".
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Sat, 16 Aug 2014 10:43:59 +0900
parents f5ff18f65b73
children d0d3e5c6eb3c
files mercurial/cmdutil.py mercurial/help/config.txt tests/test-import-merge.t tests/test-import.t
diffstat 4 files changed, 18 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Sat Aug 16 10:43:59 2014 +0900
+++ b/mercurial/cmdutil.py	Sat Aug 16 10:43:59 2014 +0900
@@ -610,7 +610,6 @@
     tmpname, message, user, date, branch, nodeid, p1, p2 = \
         patch.extract(ui, hunk)
 
-    editor = getcommiteditor(editform='import.normal', **opts)
     update = not opts.get('bypass')
     strip = opts["strip"]
     sim = float(opts.get('similarity') or 0)
@@ -688,6 +687,8 @@
                     m = None
                 else:
                     m = scmutil.matchfiles(repo, files or [])
+                editform = mergeeditform(repo[None], 'import.normal')
+                editor = getcommiteditor(editform=editform, **opts)
                 n = repo.commit(message, opts.get('user') or user,
                                 opts.get('date') or date, match=m,
                                 editor=editor, force=partial)
--- a/mercurial/help/config.txt	Sat Aug 16 10:43:59 2014 +0900
+++ b/mercurial/help/config.txt	Sat Aug 16 10:43:59 2014 +0900
@@ -406,7 +406,8 @@
 - ``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.normal`` for :hg:`import` without ``--bypass``
+- ``changeset.import.normal.merge`` for :hg:`import` on merges
+- ``changeset.import.normal.normal`` for :hg:`import` on other
 - ``changeset.mq.qnew`` for :hg:`qnew`
 - ``changeset.mq.qfold`` for :hg:`qfold`
 - ``changeset.mq.qrefresh`` for :hg:`qrefresh`
--- a/tests/test-import-merge.t	Sat Aug 16 10:43:59 2014 +0900
+++ b/tests/test-import-merge.t	Sat Aug 16 10:43:59 2014 +0900
@@ -30,6 +30,7 @@
   (branch merge, don't forget to commit)
   $ hg ci -m merge
   $ hg export . > ../merge.diff
+  $ grep -v '^merge$' ../merge.diff > ../merge.nomsg.diff
   $ cd ..
   $ hg clone -r2 repo repo2
   adding changesets
@@ -52,8 +53,13 @@
 
   $ hg up 1
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  $ hg import ../merge.diff
-  applying ../merge.diff
+  $ cat > $TESTTMP/editor.sh <<EOF
+  > env | grep HGEDITFORM
+  > echo merge > \$1
+  > EOF
+  $ HGEDITOR="sh $TESTTMP/editor.sh" hg import --edit ../merge.nomsg.diff
+  applying ../merge.nomsg.diff
+  HGEDITFORM=import.normal.merge
   $ tipparents
   1:540395c44225 changea
   3:102a90ea7b4a addb
--- a/tests/test-import.t	Sat Aug 16 10:43:59 2014 +0900
+++ b/tests/test-import.t	Sat Aug 16 10:43:59 2014 +0900
@@ -90,8 +90,13 @@
   added 1 changesets with 2 changes to 2 files
   updating to branch default
   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ HGEDITOR=cat hg --cwd b import ../diffed-tip.patch
+  $ cat > $TESTTMP/editor.sh <<EOF
+  > env | grep HGEDITFORM
+  > cat \$1
+  > EOF
+  $ HGEDITOR="sh $TESTTMP/editor.sh" hg --cwd b import ../diffed-tip.patch
   applying ../diffed-tip.patch
+  HGEDITFORM=import.normal.normal
   
   
   HG: Enter commit message.  Lines beginning with 'HG:' are removed.