templater: add hint to template parse errors to help locate issues
ClosedPublic

Authored by ryanmce on Mar 3 2018, 4:49 PM.

Details

Summary

Previously, we would print the error name and location, but this isn't as
helpful as we can be. Let's add a hint that shows the location where we
encountered the parse error.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
ryanmce created this revision.Mar 3 2018, 4:49 PM
durin42 requested changes to this revision.Mar 3 2018, 4:55 PM
durin42 added a subscriber: durin42.

We should add a test about templates that contain newlines - it's probably Hard, so feel free to just not be helpful with newline-containing templates for now?

tests/test-command-template.t
2770

Nit: could we make this be "^ here" instead of just the caret?

This revision now requires changes to proceed.Mar 3 2018, 4:55 PM
ryanmce updated this revision to Diff 6484.Mar 3 2018, 5:11 PM
pulkit added a subscriber: pulkit.Mar 3 2018, 5:17 PM

I like similar things in rust too. I am +1 on this.

durin42 accepted this revision.Mar 3 2018, 5:42 PM
This revision is now accepted and ready to land.Mar 3 2018, 5:42 PM
This revision was automatically updated to reflect the committed changes.
yuja added a subscriber: yuja.Mar 3 2018, 7:21 PM
yuja added inline comments.
mercurial/templater.py
148

Perhaps this pos + 1 is the reason why the error location is sometimes wrong.
I'll send a follow up.