changeset 7967:c03f42159afa

cmdutil: refactor handling of templating in show_changeset()
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Sat, 04 Apr 2009 17:55:52 +0200
parents aa983c3d94a9
children 43b70a964e0d
files mercurial/cmdutil.py
diffstat 1 files changed, 27 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Sat Apr 04 17:46:11 2009 +0200
+++ b/mercurial/cmdutil.py	Sat Apr 04 17:55:52 2009 +0200
@@ -912,32 +912,37 @@
         patch = matchfn or matchall(repo)
 
     tmpl = opts.get('template')
-    mapfile = None
+    style = None
     if tmpl:
         tmpl = templater.parsestring(tmpl, quoted=False)
     else:
-        mapfile = opts.get('style')
-        # ui settings
-        if not mapfile:
-            tmpl = ui.config('ui', 'logtemplate')
-            if tmpl:
-                tmpl = templater.parsestring(tmpl)
-            else:
-                mapfile = ui.config('ui', 'style')
+        style = opts.get('style')
+
+    # ui settings
+    if not (tmpl or style):
+        tmpl = ui.config('ui', 'logtemplate')
+        if tmpl:
+            tmpl = templater.parsestring(tmpl)
+        else:
+            style = ui.config('ui', 'style')
+
+    if not (tmpl or style):
+        return changeset_printer(ui, repo, patch, opts, buffered)
 
-    if tmpl or mapfile:
-        if mapfile:
-            if not os.path.split(mapfile)[0]:
-                mapname = (templater.templatepath('map-cmdline.' + mapfile)
-                           or templater.templatepath(mapfile))
-                if mapname: mapfile = mapname
-        try:
-            t = changeset_templater(ui, repo, patch, opts, mapfile, buffered)
-        except SyntaxError, inst:
-            raise util.Abort(inst.args[0])
-        if tmpl: t.use_template(tmpl)
-        return t
-    return changeset_printer(ui, repo, patch, opts, buffered)
+    mapfile = None
+    if style and not tmpl:
+        mapfile = style
+        if not os.path.split(mapfile)[0]:
+            mapname = (templater.templatepath('map-cmdline.' + mapfile)
+                       or templater.templatepath(mapfile))
+            if mapname: mapfile = mapname
+
+    try:
+        t = changeset_templater(ui, repo, patch, opts, mapfile, buffered)
+    except SyntaxError, inst:
+        raise util.Abort(inst.args[0])
+    if tmpl: t.use_template(tmpl)
+    return t
 
 def finddate(ui, repo, date):
     """Find the tipmost changeset that matches the given date spec"""