interhg: use uisetup() instead of module-load side effects
This fixes an infinite recursion bug caused by visiting a bad subpage
of the help handler repeatedly, which caused the wrapper for the
templater's escape filter to get installed twice and resulted in
infinite recursion.
--- a/hgext/interhg.py Mon Oct 18 23:20:14 2010 -0500
+++ b/hgext/interhg.py Sat Oct 16 18:09:47 2010 -0500
@@ -28,17 +28,18 @@
from mercurial import templatefilters, extensions
from mercurial.i18n import _
-orig_escape = templatefilters.filters["escape"]
-
interhg_table = []
-def interhg_escape(x):
- escstr = orig_escape(x)
- for regexp, format in interhg_table:
- escstr = regexp.sub(format, escstr)
- return escstr
+def uisetup(ui):
+ orig_escape = templatefilters.filters["escape"]
-templatefilters.filters["escape"] = interhg_escape
+ def interhg_escape(x):
+ escstr = orig_escape(x)
+ for regexp, format in interhg_table:
+ escstr = regexp.sub(format, escstr)
+ return escstr
+
+ templatefilters.filters["escape"] = interhg_escape
def interhg_refresh(orig, self, *args, **kwargs):
interhg_table[:] = []