I'm writing a mercurial extension, but am finding that template rendering is rather slow.
I was originally using cmdutil.rendertemplate()
, however, it seems that has to reparse the template string every time, which is rather slow.
When switching to the "new" api for @templatekeyword
, it looks like the first arg passed is a mercurial.templater.engine
object, which has an expand
method that caches the parsed versions of templates, which makes it much faster. Unfortunately, it doesn't expand aliases.
Does anyone know the Right Way to efficiently render templates and aliases for a mercurial extension? Right now, the only option I see is copy/pasting the portions of cmdutil.rendertemplate
and keeping my own global cache...but that feels pretty icky.