[PATCH 2 of 2] revsets: more informative syntax error message

Martin von Zweigbergk martinvonz at google.com
Tue Apr 14 00:56:30 CDT 2015


On Mon, Apr 13, 2015 at 9:34 PM Ryan McElroy <rmcelroy at fb.com> wrote:

> # HG changeset patch
> # User Ryan McElroy <rmcelroy at fb.com>
> # Date 1428983585 25200
> #      Mon Apr 13 20:53:05 2015 -0700
> # Node ID e2e2371e3b2e343224bf44b9571904eb8a88ee44
> # Parent  e92f07c0e06691df67b06488c37b8b742b667809
> revsets: more informative syntax error message
>
> I came across a case where an internal command was using a revset that I
> didn't
> immediately pass in and it was difficult to debug what was going wrong
> with the
> revset. This prints out the revset and informs the user that the error is
> with
> a rebset so it should be more obvious what and where the error is.
>
> diff --git a/mercurial/revset.py b/mercurial/revset.py
> --- a/mercurial/revset.py
> +++ b/mercurial/revset.py
> @@ -241,7 +241,8 @@ def tokenize(program, lookup=None, symin
>                  yield ('symbol', sym, s)
>              pos -= 1
>          else:
> -            raise error.ParseError(_("syntax error"), pos)
> +            raise error.ParseError(_("syntax error in revset '%s'") %
> +                                   program, pos)
>

Looks like an improvement to me, thanks. Pushing to the clowncopter.


>          pos += 1
>      yield ('end', None, pos)
>
> diff --git a/tests/test-revset.t b/tests/test-revset.t
> --- a/tests/test-revset.t
> +++ b/tests/test-revset.t
> @@ -1535,7 +1535,7 @@ test in problematic encoding
>
>  test error message of bad revset
>    $ hg log -r 'foo\\'
> -  hg: parse error at 3: syntax error
> +  hg: parse error at 3: syntax error in revset 'foo\\'
>    [255]
>
>    $ cd ..
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20150414/65d79178/attachment.html>


More information about the Mercurial-devel mailing list