diff --git a/hgext/highlight/highlight.py b/hgext/highlight/highlight.py --- a/hgext/highlight/highlight.py +++ b/hgext/highlight/highlight.py @@ -10,9 +10,7 @@ from mercurial import demandimport demandimport.ignore.extend(['pkgutil', 'pkg_resources', '__main__',]) - from mercurial import util, encoding -from mercurial.templatefilters import filters from pygments import highlight from pygments.util import ClassNotFound @@ -55,7 +53,7 @@ def pygmentize(field, fctx, style, tmpl) colorized = colorized[colorized.find('
')+5:]
     coloriter = iter(colorized.splitlines())
 
-    filters['colorize'] = lambda x: coloriter.next()
+    tmpl.filters['colorize'] = lambda x: coloriter.next()
 
     oldl = tmpl.cache[field]
     newl = oldl.replace('line|escape', 'line|colorize')
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -712,10 +712,8 @@ class changeset_templater(changeset_prin
 
     def __init__(self, ui, repo, patch, diffopts, mapfile, buffered):
         changeset_printer.__init__(self, ui, repo, patch, diffopts, buffered)
-        filters = templatefilters.filters.copy()
-        filters['formatnode'] = (ui.debugflag and (lambda x: x)
-                                 or (lambda x: x[:12]))
-        self.t = templater.templater(mapfile, filters,
+        formatnode = ui.debugflag and (lambda x: x) or (lambda x: x[:12])
+        self.t = templater.templater(mapfile, {'formatnode': formatnode},
                                      cache={
                                          'parent': '{rev}:{node|formatnode} ',
                                          'manifest': '{rev}:{node|formatnode}',
diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py
+++ b/mercurial/hgweb/hgweb_mod.py
@@ -7,8 +7,7 @@
 # GNU General Public License version 2, incorporated herein by reference.
 
 import os
-from mercurial import ui, hg, util, hook, error, encoding
-from mercurial import templater, templatefilters
+from mercurial import ui, hg, util, hook, error, encoding, templater
 from common import get_mtime, ErrorResponse
 from common import HTTP_OK, HTTP_BAD_REQUEST, HTTP_NOT_FOUND, HTTP_SERVER_ERROR
 from common import HTTP_UNAUTHORIZED, HTTP_METHOD_NOT_ALLOWED
@@ -246,7 +245,7 @@ class hgweb(object):
 
         # create the templater
 
-        tmpl = templater.templater(mapfile, templatefilters.filters,
+        tmpl = templater.templater(mapfile,
                                    defaults={"url": req.url,
                                              "staticurl": staticurl,
                                              "urlbase": urlbase,
diff --git a/mercurial/hgweb/hgwebdir_mod.py b/mercurial/hgweb/hgwebdir_mod.py
--- a/mercurial/hgweb/hgwebdir_mod.py
+++ b/mercurial/hgweb/hgwebdir_mod.py
@@ -8,7 +8,7 @@
 
 import os
 from mercurial.i18n import _
-from mercurial import ui, hg, util, templater, templatefilters
+from mercurial import ui, hg, util, templater
 from mercurial import error, encoding
 from common import ErrorResponse, get_mtime, staticfile, paritygen,\
                    get_contact, HTTP_OK, HTTP_NOT_FOUND, HTTP_SERVER_ERROR
@@ -304,7 +304,7 @@ class hgwebdir(object):
 
         style = 'style' in req.form and req.form['style'][0] or self.style
         mapfile = templater.stylemap(style)
-        tmpl = templater.templater(mapfile, templatefilters.filters,
+        tmpl = templater.templater(mapfile,
                                    defaults={"header": header,
                                              "footer": footer,
                                              "motd": motd,
diff --git a/mercurial/templatefilters.py b/mercurial/templatefilters.py
--- a/mercurial/templatefilters.py
+++ b/mercurial/templatefilters.py
@@ -8,6 +8,12 @@
 import cgi, re, os, time, urllib, textwrap
 import util, templater, encoding
 
+def stringify(thing):
+    '''turn nested template iterator into string.'''
+    if hasattr(thing, '__iter__') and not isinstance(thing, str):
+        return "".join([stringify(t) for t in thing if t is not None])
+    return str(thing)
+
 agescales = [("second", 1),
              ("minute", 60),
              ("hour", 3600),
@@ -194,7 +200,7 @@ filters = {
     "rfc3339date": lambda x: util.datestr(x, "%Y-%m-%dT%H:%M:%S%1:%2"),
     "short": lambda x: x[:12],
     "shortdate": util.shortdate,
-    "stringify": templater.stringify,
+    "stringify": stringify,
     "strip": lambda x: x.strip(),
     "urlescape": lambda x: urllib.quote(x),
     "user": lambda x: util.shortuser(x),
diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -7,9 +7,10 @@
 
 from i18n import _
 import re, sys, os
-import util, config
+import util, config, templatefilters
 
 path = ['templates', '../templates']
+stringify = templatefilters.stringify
 
 def parsestring(s, quoted=True):
     '''parse a string using simple c-like syntax.
@@ -116,7 +117,8 @@ class templater(object):
         self.cache = cache.copy()
         self.map = {}
         self.base = (mapfile and os.path.dirname(mapfile)) or ''
-        self.filters = filters
+        self.filters = templatefilters.filters.copy()
+        self.filters.update(filters)
         self.defaults = defaults
         self.minchunk, self.maxchunk = minchunk, maxchunk
 
@@ -207,9 +209,3 @@ def stylemap(style, paths=None):
                 return mapfile
 
     raise RuntimeError("No hgweb templates found in %r" % paths)
-
-def stringify(thing):
-    '''turn nested template iterator into string.'''
-    if hasattr(thing, '__iter__') and not isinstance(thing, str):
-        return "".join([stringify(t) for t in thing if t is not None])
-    return str(thing)