[PATCH 09 of 19] backout: use "getcommiteditor()" instead of explicit editor choice
FUJIWARA Katsunori
foozy at lares.dti.ne.jp
Sat May 10 11:08:44 CDT 2014
# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1399736976 -32400
# Sun May 11 00:49:36 2014 +0900
# Node ID 6d924c0096511eb1918cc9746a2acacff8be77e6
# Parent aeb3911dc46526a09c3153a563090b7efcae3bb8
backout: use "getcommiteditor()" instead of explicit editor choice
This patch also enhances "test-backout.t", because "hg backout" hasn't
been explicitly tested around editor invocation and '--edit' option.
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -488,11 +488,11 @@
def commitfunc(ui, repo, message, match, opts):
- e = cmdutil.commiteditor
+ e = cmdutil.getcommiteditor()
if not message:
# we don't translate commit messages
message = "Backed out changeset %s" % short(node)
- e = cmdutil.commitforceeditor
+ e = cmdutil.getcommiteditor(edit=True)
return repo.commit(message, opts.get('user'), opts.get('date'),
match, editor=e)
newnode = cmdutil.commit(ui, repo, commitfunc, [], opts)
diff --git a/tests/test-backout.t b/tests/test-backout.t
--- a/tests/test-backout.t
+++ b/tests/test-backout.t
@@ -11,6 +11,8 @@
[255]
basic operation
+(this also tests that editor is invoked if the commit message is not
+specified explicitly)
$ echo a > a
$ hg commit -d '0 0' -A -m a
@@ -18,8 +20,19 @@
$ echo b >> a
$ hg commit -d '1 0' -m b
- $ hg backout -d '2 0' tip --tool=true
+ $ hg status --rev tip --rev "tip^1"
+ M a
+ $ HGEDITOR=cat hg backout -d '2 0' tip --tool=true
reverting a
+ Backed out changeset a820f4f40a57
+
+
+ HG: Enter commit message. Lines beginning with 'HG:' are removed.
+ HG: Leave message empty to abort commit.
+ HG: --
+ HG: user: test
+ HG: branch 'default'
+ HG: changed a
changeset 2:2929462c3dff backs out changeset 1:a820f4f40a57
$ cat a
a
@@ -31,6 +44,8 @@
update: (current)
file that was removed is recreated
+(this also tests that editor is not invoked if the commit message is
+specified explicitly)
$ cd ..
$ hg init remove
@@ -43,7 +58,7 @@
$ hg rm a
$ hg commit -d '1 0' -m b
- $ hg backout -d '2 0' tip --tool=true
+ $ HGEDITOR=cat hg backout -d '2 0' tip --tool=true -m "Backed out changeset 76862dcce372"
adding a
changeset 2:de31bdc76c0d backs out changeset 1:76862dcce372
$ cat a
More information about the Mercurial-devel
mailing list