Patchwork [4,of,6] backout: accept '--edit' like other commands creating new changeset

login
register
mail settings
Submitter Katsunori FUJIWARA
Date May 31, 2014, 3:26 p.m.
Message ID <78dce791e39b7d0d8776.1401549974@feefifofum>
Download mbox | patch
Permalink /patch/4909/
State Accepted
Headers show

Comments

Katsunori FUJIWARA - May 31, 2014, 3:26 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1401548912 -32400
#      Sun Jun 01 00:08:32 2014 +0900
# Node ID 78dce791e39b7d0d8776b9add44ebc126a135a2f
# Parent  ada6d06aa6bdf3edf5d0fca7acf7e1e5554e8f53
backout: accept '--edit' like other commands creating new changeset

After this patch, users can invoke editor for the commit message by
'--edit' option regardless of '--message'/'--logfile'.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -386,6 +386,7 @@ 
     ('', 'parent', '',
      _('parent to choose when backing out merge (DEPRECATED)'), _('REV')),
     ('r', 'rev', '', _('revision to backout'), _('REV')),
+    ('e', 'edit', False, _('invoke editor on commit messages')),
     ] + mergetoolopts + walkopts + commitopts + commitopts2,
     _('[OPTION]... [-r] REV'))
 def backout(ui, repo, node=None, rev=None, **opts):
@@ -488,7 +489,7 @@ 
 
 
         def commitfunc(ui, repo, message, match, opts):
-            e = cmdutil.getcommiteditor()
+            e = cmdutil.getcommiteditor(**opts)
             if not message:
                 # we don't translate commit messages
                 message = "Backed out changeset %s" % short(node)
diff --git a/tests/test-backout.t b/tests/test-backout.t
--- a/tests/test-backout.t
+++ b/tests/test-backout.t
@@ -355,9 +355,21 @@ 
   update: (current)
 
 with --merge
+(this also tests that editor is invoked if '--edit' is specified
+explicitly regardless of '--message')
+
   $ hg update -qC
-  $ hg backout --merge -d '3 0' -r 1 -m 'backout on branch1' --tool=true
+  $ HGEDITOR=cat hg backout --merge -d '3 0' -r 1 -m 'backout on branch1' --tool=true --edit
   removing file1
+  backout on branch1
+  
+  
+  HG: Enter commit message.  Lines beginning with 'HG:' are removed.
+  HG: Leave message empty to abort commit.
+  HG: --
+  HG: user: test
+  HG: branch 'branch2'
+  HG: removed file1
   created new head
   changeset 3:d4e8f6db59fb backs out changeset 1:bf1602f437f3
   merging with changeset 3:d4e8f6db59fb
diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -215,7 +215,7 @@ 
   update: clean, check, date, rev, tool
   addremove: similarity, include, exclude, dry-run
   archive: no-decode, prefix, rev, type, subrepos, include, exclude
-  backout: merge, parent, rev, tool, include, exclude, message, logfile, date, user
+  backout: merge, parent, rev, edit, tool, include, exclude, message, logfile, date, user
   bisect: reset, good, bad, skip, extend, command, noupdate
   bookmarks: force, rev, delete, rename, inactive
   branch: force, clean