changeset 22582:4fe5fa49eac8 stable

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' ...
author Yuya Nishihara <yuya@tcha.org>
date Tue, 30 Sep 2014 23:15:56 +0900
parents a111e460318a
children cd1b43226b34 551d776a0a9a
files mercurial/cmdutil.py tests/test-command-template.t
diffstat 2 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Sat Sep 27 21:59:55 2014 +0900
+++ b/mercurial/cmdutil.py	Tue Sep 30 23:15:56 2014 +0900
@@ -1087,7 +1087,7 @@
     """
 
     # ui settings
-    if not tmpl and not style:
+    if not tmpl and not style: # template are stronger than style
         tmpl = ui.config('ui', 'logtemplate')
         if tmpl:
             try:
@@ -1098,7 +1098,7 @@
         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)
--- a/tests/test-command-template.t	Sat Sep 27 21:59:55 2014 +0900
+++ b/tests/test-command-template.t	Tue Sep 30 23:15:56 2014 +0900
@@ -86,6 +86,11 @@
   $ 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