Patchwork highlight: get around tmpl.load() which now returns a parsed tree

login
register
mail settings
Submitter Yuya Nishihara
Date June 18, 2018, 1:05 p.m.
Message ID <140cfc3770b87c8aad8c.1529327141@mimosa>
Download mbox | patch
Permalink /patch/32268/
State Accepted
Headers show

Comments

Yuya Nishihara - June 18, 2018, 1:05 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1529326492 -32400
#      Mon Jun 18 21:54:52 2018 +0900
# Node ID 140cfc3770b87c8aad8cbe3be9f21a02f3636ef3
# Parent  f4f1fb1cbfb42fb24b7b546f39b35f1bf5a7267c
highlight: get around tmpl.load() which now returns a parsed tree

Broken at e637dc0b3b1f, "templater: parse template string to tree by
templater class."
via Mercurial-devel - June 18, 2018, 4:08 p.m.
Queued, thanks!

On Mon, Jun 18, 2018 at 6:05 AM Yuya Nishihara <yuya@tcha.org> wrote:

> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1529326492 -32400
> #      Mon Jun 18 21:54:52 2018 +0900
> # Node ID 140cfc3770b87c8aad8cbe3be9f21a02f3636ef3
> # Parent  f4f1fb1cbfb42fb24b7b546f39b35f1bf5a7267c
> highlight: get around tmpl.load() which now returns a parsed tree
>
> Broken at e637dc0b3b1f, "templater: parse template string to tree by
> templater class."
>
> diff --git a/hgext/highlight/highlight.py b/hgext/highlight/highlight.py
> --- a/hgext/highlight/highlight.py
> +++ b/hgext/highlight/highlight.py
> @@ -44,7 +44,8 @@ SYNTAX_CSS = ('\n<link rel="stylesheet"
>  def pygmentize(field, fctx, style, tmpl, guessfilenameonly=False):
>
>      # append a <link ...> to the syntax highlighting css
> -    old_header = tmpl.load('header')
> +    tmpl.load('header')
> +    old_header = tmpl.cache['header']
>      if SYNTAX_CSS not in old_header:
>          new_header = old_header + SYNTAX_CSS
>          tmpl.cache['header'] = new_header
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>

Patch

diff --git a/hgext/highlight/highlight.py b/hgext/highlight/highlight.py
--- a/hgext/highlight/highlight.py
+++ b/hgext/highlight/highlight.py
@@ -44,7 +44,8 @@  SYNTAX_CSS = ('\n<link rel="stylesheet" 
 def pygmentize(field, fctx, style, tmpl, guessfilenameonly=False):
 
     # append a <link ...> to the syntax highlighting css
-    old_header = tmpl.load('header')
+    tmpl.load('header')
+    old_header = tmpl.cache['header']
     if SYNTAX_CSS not in old_header:
         new_header = old_header + SYNTAX_CSS
         tmpl.cache['header'] = new_header