templating compatibility between 3.4 and 4.1
Danek Duvall
danek.duvall at oracle.com
Wed Apr 19 20:22:29 UTC 2017
Danek Duvall wrote:
> We're trying to roll out a cute bit of templating-fu that does some
> highlighting of keywords in descriptions. It works pretty well.
> Unfortunately, the same style file doesn't work on both 3.4 (which is still
> in reasonably heavy use) and later versions (3.7, 4.1). I know there were
> some BC changes in 3.5, so I assume we're running into those, but I'm
> wondering if there's some way to write the templates so they work across
> versions.
>
> I'm happy to share the full version of the template, but here's a simple
> test case. It has to do with sub() and using backreferences, and the
> quoting involved.
>
> If I specify the template on the commandline, it works just fine on both
> versions (this is a recent changeset in the mercurial repo):
>
> $ hg log -r ed42e00a5c4e -T '{sub("pro(gress)", "con\\1", desc)}\n'
>
> but if I move the template to a style file:
>
> $ cat /tmp/hgstyle
> changeset = '{sub('pro(gress)', 'con\\1', desc)}'
> $ hg log -r ed42e00a5c4e --config ui.style=/tmp/hgstyle
>
> then while this work with 4.1, I get a ^A character where I should simply
> see "gress". I can get it to work with 3.4 if I use "r'con\\1'", but then
> that doesn't work with 4.1 -- it gives me a literal "\1".
>
> Is there anything we can do here, or are we going to be limited to using
> one style file when using 3.4, and another when using something more
> recent?
One solution another colleague suggested was to use an alternate form of
backreference, something I hadn't seriously considered. Using \g<1> works
in both versions like a charm.
Danek
More information about the Mercurial
mailing list