541 def parse(spec, lookup=None): |
541 def parse(spec, lookup=None): |
542 try: |
542 try: |
543 return _parsewith(spec, lookup=lookup) |
543 return _parsewith(spec, lookup=lookup) |
544 except error.ParseError as inst: |
544 except error.ParseError as inst: |
545 if len(inst.args) > 1: # has location |
545 if len(inst.args) > 1: # has location |
546 # Add 1 to location because unlike templates, revset parse errors |
546 loc = inst.args[1] |
547 # point to the char where the error happened, not the char after. |
|
548 loc = inst.args[1] + 1 |
|
549 # Remove newlines -- spaces are equivalent whitespace. |
547 # Remove newlines -- spaces are equivalent whitespace. |
550 spec = spec.replace('\n', ' ') |
548 spec = spec.replace('\n', ' ') |
551 # We want the caret to point to the place in the template that |
549 # We want the caret to point to the place in the template that |
552 # failed to parse, but in a hint we get a open paren at the |
550 # failed to parse, but in a hint we get a open paren at the |
553 # start. Therefore, we print "loc + 1" spaces (instead of "loc") |
551 # start. Therefore, we print "loc + 1" spaces (instead of "loc") |
554 # to line up the caret with the location of the error. |
552 # to line up the caret with the location of the error. |
555 inst.hint = spec + '\n' + ' ' * loc + '^ ' + _('here') |
553 inst.hint = spec + '\n' + ' ' * (loc + 1) + '^ ' + _('here') |
556 raise |
554 raise |
557 |
555 |
558 def _quote(s): |
556 def _quote(s): |
559 r"""Quote a value in order to make it safe for the revset engine. |
557 r"""Quote a value in order to make it safe for the revset engine. |
560 |
558 |