Mercurial > public > mercurial-scm > hg-stable
diff mercurial/revsetlang.py @ 36716:1b179d151578
templater: fix position of terminator character in error message
Since a template expression starts after the '{' character, the expression
should be considered to end immediately before the terminator '{'.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 04 Mar 2018 07:03:50 -0500 |
parents | 2a258985ffeb |
children | f0b6fbea00cf |
line wrap: on
line diff
--- a/mercurial/revsetlang.py Sun Mar 04 10:42:51 2018 -0500 +++ b/mercurial/revsetlang.py Sun Mar 04 07:03:50 2018 -0500 @@ -543,16 +543,14 @@ return _parsewith(spec, lookup=lookup) except error.ParseError as inst: if len(inst.args) > 1: # has location - # Add 1 to location because unlike templates, revset parse errors - # point to the char where the error happened, not the char after. - loc = inst.args[1] + 1 + loc = inst.args[1] # Remove newlines -- spaces are equivalent whitespace. spec = spec.replace('\n', ' ') # We want the caret to point to the place in the template that # failed to parse, but in a hint we get a open paren at the # start. Therefore, we print "loc + 1" spaces (instead of "loc") # to line up the caret with the location of the error. - inst.hint = spec + '\n' + ' ' * loc + '^ ' + _('here') + inst.hint = spec + '\n' + ' ' * (loc + 1) + '^ ' + _('here') raise def _quote(s):