[PATCH] extensions: suggest --config extensions.bad=! when bad fails

Pierre-Yves David pierre-yves.david at ens-lyon.org
Tue Sep 22 16:53:09 CDT 2015



On 09/18/2015 04:38 AM, timeless at mozdev.org wrote:
> # HG changeset patch
> # User timeless at mozdev.org
> # Date 1441928905 14400
> #      Thu Sep 10 19:48:25 2015 -0400
> # Node ID 5f61789ec5c7e1f6277fb857d4c61214a857b0cd
> # Parent  a0eff7ebc2aebb32cf4c8da276104102ff37d786
> extensions: suggest --config extensions.bad=! when bad fails
>
> There are lots of ways for extensions to fail, so users should
> be given a hint about how to deal with them, instead of being
> left to scratch their heads.

Not entirely enthousiastic about it. IF a user enable an extensions it 
should be able to disable it. But knowing that users are users, this is 
probably a bit too optimistic.

However, temporary (--config) way to disable extensions is probably a 
bad sugguest in the "fail to import case" where there is low chance this 
will start importing again for the next run.

Hi like Kevin proposal of listing all possible offender instead of the 
first one.

> diff --git a/mercurial/extensions.py b/mercurial/extensions.py
> --- a/mercurial/extensions.py
> +++ b/mercurial/extensions.py
> @@ -119,11 +119,13 @@
>               raise
>           except Exception as inst:
>               if path:
> -                ui.warn(_("*** failed to import extension %s from %s: %s\n")
> -                        % (name, path, inst))
> +                ui.warn(_("*** failed to import extension %(n)s from %(p)s: %(i)s\n"
> +                          "(you can use '--config extensions.%(n)s=!' to disable it)\n")
> +                        % {'n': name, 'p': path, 'i': inst})
>               else:
> -                ui.warn(_("*** failed to import extension %s: %s\n")
> -                        % (name, inst))
> +                ui.warn(_("*** failed to import extension %(n)s: %(i)s\n"
> +                          "(you can use '--config extensions.%(n)s=!' to disable it)\n")
> +                        % {'n': name, 'i': inst})
>               ui.traceback()
>
>       for name in _order[newindex:]:
> diff --git a/tests/test-bad-extension.t b/tests/test-bad-extension.t
> --- a/tests/test-bad-extension.t
> +++ b/tests/test-bad-extension.t
> @@ -11,15 +11,19 @@
>
>     $ hg -q help help 2>&1 |grep extension
>     *** failed to import extension badext from $TESTTMP/badext.py: bit bucket overflow
> +  (you can use '--config extensions.badext=!' to disable it)
>     *** failed to import extension badext2: No module named badext2
> +  (you can use '--config extensions.badext2=!' to disable it)
>
>   show traceback
>
>     $ hg -q help help --traceback 2>&1 | egrep ' extension|^Exception|Traceback|ImportError'
>     *** failed to import extension badext from $TESTTMP/badext.py: bit bucket overflow
> +  (you can use '--config extensions.badext=!' to disable it)
>     Traceback (most recent call last):
>     Exception: bit bucket overflow
>     *** failed to import extension badext2: No module named badext2
> +  (you can use '--config extensions.badext2=!' to disable it)
>     Traceback (most recent call last):
>     ImportError: No module named badext2
>
> @@ -30,11 +34,13 @@
>     > | grep -v '^ ' \
>     > | egrep 'extension..[^p]|^Exception|Traceback|ImportError|not import'
>     *** failed to import extension badext from $TESTTMP/badext.py: bit bucket overflow
> +  (you can use '--config extensions.badext=!' to disable it)
>     Traceback (most recent call last):
>     Exception: bit bucket overflow
>     could not import hgext.badext2 (No module named badext2): trying badext2
>     Traceback (most recent call last):
>     ImportError: No module named badext2
>     *** failed to import extension badext2: No module named badext2
> +  (you can use '--config extensions.badext2=!' to disable it)
>     Traceback (most recent call last):
>     ImportError: No module named badext2
> diff --git a/tests/test-qrecord.t b/tests/test-qrecord.t
> --- a/tests/test-qrecord.t
> +++ b/tests/test-qrecord.t
> @@ -110,6 +110,7 @@
>     $ echo "mq=nonexistent" >> $HGRCPATH
>     $ hg help qrecord
>     *** failed to import extension mq from nonexistent: [Errno *] * (glob)
> +  (you can use '--config extensions.mq=!' to disable it)
>     hg qrecord [OPTION]... PATCH [FILE]...
>
>     interactively record a new patch


-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list