[PATCH 1 of 1] interhg: use uisetup() instead of module-load side effects

Augie Fackler durin42 at gmail.com
Tue Oct 19 09:58:05 CDT 2010


Ping. This fixes bad behavior caused by the help page in hgweb.

On Oct 16, 2010, at 6:10 PM, Augie Fackler wrote:

> # HG changeset patch
> # User Augie Fackler <durin42 at gmail.com>
> # Date 1287270587 18000
> # Node ID 3b0b059cbcfde8e5141aed97b057eb0ee07b1623
> # Parent  7c6813db1e8b9fda385eeb3d8f551aafb309739b
> 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.
>
> diff --git a/hgext/interhg.py b/hgext/interhg.py
> --- a/hgext/interhg.py
> +++ b/hgext/interhg.py
> @@ -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[:] = []
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel



More information about the Mercurial-devel mailing list