Patchwork [7,of,8] rebase: change "editform" to distinguish merge commits from other

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Aug. 15, 2014, 2:09 p.m.
Message ID <e1ee4f6aba1c73822483.1408111765@feefifofum>
Download mbox | patch
Permalink /patch/5421/
State Changes Requested
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 e1ee4f6aba1c73822483c8a3fe5d89a6829b3a81
# Parent  b75e08f42ff6627fa693bc99f8ada686ae66a6ab
rebase: change "editform" to distinguish merge commits from other

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

  EXTENSION[.COMMAND][.ROUTE]

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

This patch newly adds "merge" as ROUTE, to distinguish merge commits
from other.

Unlike other patches in this series (e.g. for "hg commit"), this patch
doesn't add "normal.normal"/"normal.merge" style ROUTEs, because there
is no "merge" case in "collapse" ROUTE.

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -138,7 +138,6 @@ 
     skipped = set()
     targetancestors = set()
 
-    editor = cmdutil.getcommiteditor(editform='rebase.normal', **opts)
 
     lock = wlock = None
     try:
@@ -354,6 +353,11 @@ 
                     p1rev = repo[rev].p1().rev()
                     cmdutil.duplicatecopies(repo, rev, p1rev, skiprev=target)
                 if not collapsef:
+                    if repo[p2].rev() != nullrev:
+                        editform = 'rebase.merge'
+                    else:
+                        editform = 'rebase.normal'
+                    editor = cmdutil.getcommiteditor(editform=editform, **opts)
                     newrev = concludenode(repo, rev, p1, p2, extrafn=extrafn,
                                           editor=editor)
                 else:
diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
--- a/mercurial/help/config.txt
+++ b/mercurial/help/config.txt
@@ -413,7 +413,8 @@ 
 - ``changeset.mq.qfold`` for :hg:`qfold`
 - ``changeset.mq.qrefresh`` for :hg:`qrefresh`
 - ``changeset.rebase.collapse`` for :hg:`rebase --collapse`
-- ``changeset.rebase.normal`` for :hg:`rebase` without ``--collapse``
+- ``changeset.rebase.merge`` for :hg:`rebase` on merges
+- ``changeset.rebase.normal`` for :hg:`rebase` on other
 - ``changeset.shelve.shelve`` for :hg:`shelve`
 - ``changeset.tag.add`` for :hg:`tag` without ``--remove``
 - ``changeset.tag.remove`` for :hg:`tag --remove`
diff --git a/tests/test-rebase-cache.t b/tests/test-rebase-cache.t
--- a/tests/test-rebase-cache.t
+++ b/tests/test-rebase-cache.t
@@ -470,5 +470,11 @@ 
   o  0 A public
   
 
-  $ hg rebase --dest 7 --source 5
+  $ cat > $TESTTMP/checkeditform.sh <<EOF
+  > env | grep HGEDITFORM
+  > true
+  > EOF
+  $ HGEDITOR="sh $TESTTMP/checkeditform.sh" hg rebase --dest 7 --source 5 -e
+  HGEDITFORM=rebase.merge
+  HGEDITFORM=rebase.normal
   saved backup bundle to $TESTTMP/a3/c4/.hg/strip-backup/*-backup.hg (glob)