Patchwork [STABLE] templater: fix precedence of --style and --template options

login
register
mail settings
Submitter Yuya Nishihara
Date Sept. 30, 2014, 3:03 p.m.
Message ID <8272dfdaa3985cb2ab59.1412089428@mimosa>
Download mbox | patch
Permalink /patch/6037/
State Accepted
Headers show

Comments

Yuya Nishihara - Sept. 30, 2014, 3:03 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1412086556 -32400
#      Tue Sep 30 23:15:56 2014 +0900
# Branch stable
# Node ID 8272dfdaa3985cb2ab59e479594a799e91da0395
# Parent  a111e460318af49aeb6578cf142a63426c5e764d
templater: fix precedence of --style and --template options

Since e3eb480a9391, --template option is ignored if --style is specified,
which is wrong according to the doc of show_changeset():

    Display format will be the first non-empty hit of:
    1. option 'template'
    2. option 'style'
    ...
Pierre-Yves David - Sept. 30, 2014, 3:57 p.m.
On 09/30/2014 10:03 AM, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1412086556 -32400
> #      Tue Sep 30 23:15:56 2014 +0900
> # Branch stable
> # Node ID 8272dfdaa3985cb2ab59e479594a799e91da0395
> # Parent  a111e460318af49aeb6578cf142a63426c5e764d
> templater: fix precedence of --style and --template options

pushed to the clowncopter with the following tweak:

-    if not tmpl and not style:
+    if not tmpl and not style: # template are stronger than style

Thanks.
Yuya Nishihara - Oct. 1, 2014, 1:04 p.m.
On Tue, 30 Sep 2014 10:57:38 -0500, Pierre-Yves David wrote:
> On 09/30/2014 10:03 AM, Yuya Nishihara wrote:
> > # HG changeset patch
> > # User Yuya Nishihara <yuya@tcha.org>
> > # Date 1412086556 -32400
> > #      Tue Sep 30 23:15:56 2014 +0900
> > # Branch stable
> > # Node ID 8272dfdaa3985cb2ab59e479594a799e91da0395
> > # Parent  a111e460318af49aeb6578cf142a63426c5e764d
> > templater: fix precedence of --style and --template options
> 
> pushed to the clowncopter with the following tweak:
> 
> -    if not tmpl and not style:
> +    if not tmpl and not style: # template are stronger than style

I flagged this as stable because it is a regression in Mercurial 3.0.

Regards,
Pierre-Yves David - Oct. 1, 2014, 5:14 p.m.
On 10/01/2014 08:04 AM, Yuya Nishihara wrote:
> On Tue, 30 Sep 2014 10:57:38 -0500, Pierre-Yves David wrote:
>> On 09/30/2014 10:03 AM, Yuya Nishihara wrote:
>>> # HG changeset patch
>>> # User Yuya Nishihara <yuya@tcha.org>
>>> # Date 1412086556 -32400
>>> #      Tue Sep 30 23:15:56 2014 +0900
>>> # Branch stable
>>> # Node ID 8272dfdaa3985cb2ab59e479594a799e91da0395
>>> # Parent  a111e460318af49aeb6578cf142a63426c5e764d
>>> templater: fix precedence of --style and --template options
>>
>> pushed to the clowncopter with the following tweak:
>>
>> -    if not tmpl and not style:
>> +    if not tmpl and not style: # template are stronger than style
>
> I flagged this as stable because it is a regression in Mercurial 3.0.

Matt spotted it and fixed it.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1098,7 +1098,7 @@  def gettemplate(ui, tmpl, style):
         else:
             style = util.expandpath(ui.config('ui', 'style', ''))
 
-    if style:
+    if not tmpl and style:
         mapfile = style
         if not os.path.split(mapfile)[0]:
             mapname = (templater.templatepath('map-cmdline.' + mapfile)
diff --git a/tests/test-command-template.t b/tests/test-command-template.t
--- a/tests/test-command-template.t
+++ b/tests/test-command-template.t
@@ -86,6 +86,11 @@  Test templates and style maps in files:
   $ hg log -l1 -T./map-simple
   8
 
+Template should precede style option
+
+  $ hg log -l1 --style default -T '{rev}\n'
+  8
+
 Default style is like normal output:
 
   $ hg log > log.out