fix template bug that made hgweb break.
problem found by Shun-ichi Goto <shunichi.goto@gmail.com>.
this fix tested with command template and hgweb templates.
--- a/mercurial/hgweb.py Wed Mar 15 11:26:57 2006 +0100
+++ b/mercurial/hgweb.py Wed Mar 15 11:28:00 2006 -0800
@@ -797,11 +797,11 @@
or uri.strip('/') or self.repo.root)
self.t = templater.templater(m, templater.common_filters,
- {"url": url,
- "repo": self.reponame,
- "header": header,
- "footer": footer,
- })
+ defaults={"url": url,
+ "repo": self.reponame,
+ "header": header,
+ "footer": footer,
+ })
if not req.form.has_key('cmd'):
req.form['cmd'] = [self.t.cache['default'],]
@@ -1030,7 +1030,8 @@
m = os.path.join(templater.templatepath(), "map")
tmpl = templater.templater(m, templater.common_filters,
- {"header": header, "footer": footer})
+ defaults={"header": header,
+ "footer": footer})
def entries(**map):
parity = 0
--- a/mercurial/templater.py Wed Mar 15 11:26:57 2006 +0100
+++ b/mercurial/templater.py Wed Mar 15 11:28:00 2006 -0800
@@ -59,18 +59,17 @@
filter uses function to transform value. syntax is
{key|filter1|filter2|...}.'''
- def __init__(self, mapfile, filters={}, cache={}):
+ def __init__(self, mapfile, filters={}, defaults={}, cache={}):
'''set up template engine.
mapfile is name of file to read map definitions from.
filters is dict of functions. each transforms a value into another.
defaults is dict of default map definitions.'''
self.mapfile = mapfile or 'template'
- self.cache = {}
+ self.cache = cache
self.map = {}
self.base = (mapfile and os.path.dirname(mapfile)) or ''
self.filters = filters
- self.defaults = {}
- self.cache = cache
+ self.defaults = defaults
if not mapfile:
return