Patchwork [08,of,19] backout: avoid redundant message examination

login
register
mail settings
Submitter Katsunori FUJIWARA
Date May 10, 2014, 4:08 p.m.
Message ID <aeb3911dc46526a09c31.1399738123@feefifofum>
Download mbox | patch
Permalink /patch/4710/
State Accepted
Headers show

Comments

Katsunori FUJIWARA - May 10, 2014, 4:08 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1399736975 -32400
#      Sun May 11 00:49:35 2014 +0900
# Node ID aeb3911dc46526a09c3153a563090b7efcae3bb8
# Parent  2bd458f23c2d86e82555d7868918d4a349a04c18
backout: avoid redundant message examination

Before this patch, "hg backout" examines "--message" and "--logfile"
options explicitly.

But this examination is redundant, because "commitfunc()" can receive
the result of same examination by "cmdutil.logmessage()" in
"cmdutil.commit()" through "message" argument.

This patch avoids redundant message examination by "message"
examination in "commitfunc()".

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -487,13 +487,12 @@ 
             cmdutil.revert(ui, repo, rctx, repo.dirstate.parents())
 
 
-        e = cmdutil.commiteditor
-        if not opts['message'] and not opts['logfile']:
-            # we don't translate commit messages
-            opts['message'] = "Backed out changeset %s" % short(node)
-            e = cmdutil.commitforceeditor
-
         def commitfunc(ui, repo, message, match, opts):
+            e = cmdutil.commiteditor
+            if not message:
+                # we don't translate commit messages
+                message = "Backed out changeset %s" % short(node)
+                e = cmdutil.commitforceeditor
             return repo.commit(message, opts.get('user'), opts.get('date'),
                                match, editor=e)
         newnode = cmdutil.commit(ui, repo, commitfunc, [], opts)