diff mercurial/hgweb/hgweb_mod.py @ 9842:d3dbdca92458

hgweb: don't choke when an inexistent style is requested (issue1901)
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Thu, 12 Nov 2009 16:39:11 +0100
parents 0e080d519d1b
children 38170eeed18c 25e572394f5c
line wrap: on
line diff
--- a/mercurial/hgweb/hgweb_mod.py	Thu Nov 12 10:29:40 2009 -0500
+++ b/mercurial/hgweb/hgweb_mod.py	Thu Nov 12 16:39:11 2009 +0100
@@ -237,14 +237,17 @@
         # figure out which style to use
 
         vars = {}
-        style = self.config("web", "style", "paper")
-        if 'style' in req.form:
-            style = req.form['style'][0]
+        styles = (
+            req.form.get('style', [None])[0],
+            self.config('web', 'style'),
+            'paper',
+        )
+        style, mapfile = templater.stylemap(styles, self.templatepath)
+        if style == styles[0]:
             vars['style'] = style
 
         start = req.url[-1] == '?' and '&' or '?'
         sessionvars = webutil.sessionvars(vars, start)
-        mapfile = templater.stylemap(style, self.templatepath)
 
         if not self.reponame:
             self.reponame = (self.config("web", "name")