[PATCH 2 of 2] parser: shorten prefix of alias parsing errors

timeless timeless at gmail.com
Tue May 3 11:36:50 EDT 2016


lgtm

On Tue, May 3, 2016 at 5:26 AM, Yuya Nishihara <yuya at tcha.org> wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya at tcha.org>
> # Date 1460863866 -32400
> #      Sun Apr 17 12:31:06 2016 +0900
> # Node ID b60f3a8fcfb997986159ea3cac027e87e76cc2ef
> # Parent  1e5af1f4c226d107dd8be4226de2a359ad1fc11b
> parser: shorten prefix of alias parsing errors
>
> These messages seemed to be a bit long. We should try making them fit to
> 80-col console.
>
> diff --git a/mercurial/parser.py b/mercurial/parser.py
> --- a/mercurial/parser.py
> +++ b/mercurial/parser.py
> @@ -447,15 +447,13 @@ class basealiasrules(object):
>          repl = efmt = None
>          name, args, err = cls._builddecl(decl)
>          if err:
> -            efmt = _('failed to parse the declaration of %(section)s '
> -                     '"%(name)s": %(error)s')
> +            efmt = _('bad declaration of %(section)s "%(name)s": %(error)s')
>          else:
>              try:
>                  repl = cls._builddefn(defn, args)
>              except error.ParseError as inst:
>                  err = parseerrordetail(inst)
> -                efmt = _('failed to parse the definition of %(section)s '
> -                         '"%(name)s": %(error)s')
> +                efmt = _('bad definition of %(section)s "%(name)s": %(error)s')
>          if err:
>              err = efmt % {'section': cls._section, 'name': name, 'error': err}
>          return alias(name, args, err, repl)
> diff --git a/tests/test-command-template.t b/tests/test-command-template.t
> --- a/tests/test-command-template.t
> +++ b/tests/test-command-template.t
> @@ -3768,10 +3768,10 @@ Unparsable alias:
>    $ hg debugtemplate --config templatealias.bad='x(' -v '{bad}'
>    (template
>      ('symbol', 'bad'))
> -  abort: failed to parse the definition of template alias "bad": at 2: not a prefix: end
> +  abort: bad definition of template alias "bad": at 2: not a prefix: end
>    [255]
>    $ hg log --config templatealias.bad='x(' -T '{bad}'
> -  abort: failed to parse the definition of template alias "bad": at 2: not a prefix: end
> +  abort: bad definition of template alias "bad": at 2: not a prefix: end
>    [255]
>
>    $ cd ..
> diff --git a/tests/test-revset.t b/tests/test-revset.t
> --- a/tests/test-revset.t
> +++ b/tests/test-revset.t
> @@ -1967,12 +1967,12 @@ test unknown reference:
>    (func
>      ('symbol', 'unknownref')
>      ('symbol', '0'))
> -  abort: failed to parse the definition of revset alias "unknownref": invalid symbol '$2'
> +  abort: bad definition of revset alias "unknownref": invalid symbol '$2'
>    [255]
>
>    $ hg debugrevspec --debug --config revsetalias.anotherbadone='branch(' "tip"
>    ('symbol', 'tip')
> -  warning: failed to parse the definition of revset alias "anotherbadone": at 7: not a prefix: end
> +  warning: bad definition of revset alias "anotherbadone": at 7: not a prefix: end
>    * set:
>    <baseset [9]>
>    9
> @@ -1985,7 +1985,7 @@ test unknown reference:
>
>    $ hg debugrevspec --debug --config revsetalias.'bad name'='tip' "tip"
>    ('symbol', 'tip')
> -  warning: failed to parse the declaration of revset alias "bad name": at 4: invalid token
> +  warning: bad declaration of revset alias "bad name": at 4: invalid token
>    * set:
>    <baseset [9]>
>    9
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list