templater: fix precedence of --style and --template options

Since 266cfa7de44d, --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'
    ...
This commit is contained in:
Yuya Nishihara 2014-09-30 23:15:56 +09:00
parent 1119de7215
commit 525193c247
2 changed files with 7 additions and 2 deletions

View File

@ -1087,7 +1087,7 @@ def gettemplate(ui, tmpl, style):
""" """
# ui settings # ui settings
if not tmpl and not style: if not tmpl and not style: # template are stronger than style
tmpl = ui.config('ui', 'logtemplate') tmpl = ui.config('ui', 'logtemplate')
if tmpl: if tmpl:
try: try:
@ -1098,7 +1098,7 @@ def gettemplate(ui, tmpl, style):
else: else:
style = util.expandpath(ui.config('ui', 'style', '')) style = util.expandpath(ui.config('ui', 'style', ''))
if style: if not tmpl and style:
mapfile = style mapfile = style
if not os.path.split(mapfile)[0]: if not os.path.split(mapfile)[0]:
mapname = (templater.templatepath('map-cmdline.' + mapfile) mapname = (templater.templatepath('map-cmdline.' + mapfile)

View File

@ -86,6 +86,11 @@ Test templates and style maps in files:
$ hg log -l1 -T./map-simple $ hg log -l1 -T./map-simple
8 8
Template should precede style option
$ hg log -l1 --style default -T '{rev}\n'
8
Default style is like normal output: Default style is like normal output:
$ hg log > log.out $ hg log > log.out