[PATCH 3 of 3] extensions: warn extsetup() as deprecated when used

TK Soh teekaysoh at gmail.com
Mon Oct 12 18:37:44 CDT 2009


On Mon, Oct 12, 2009 at 10:59 PM, Yuya Nishihara <yuya at tcha.org> wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya at tcha.org>
> # Date 1255384750 -32400
> # Node ID 90fbcdd37d891eeead38e9abdec3499338b763c9
> # Parent  3560b54e195280d339f9b6b78cf7b1d07196d1ad
> extensions: warn extsetup() as deprecated when used

Is this really necessary? It can be very annoying especially for 3rd
party extensions which not that quick to pick up any changes in
mercurial API.

> extsetup() is quite similar to uisetup() since 1c83938b6a8e change.
> it's worth to be deprecated.
>
> diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
> --- a/mercurial/dispatch.py
> +++ b/mercurial/dispatch.py
> @@ -363,6 +363,9 @@ def _dispatch(ui, args):
>     for name, module in exts:
>         extsetup = getattr(module, 'extsetup', None)
>         if extsetup:
> +            import warnings
> +            warnings.warn('extsetup() is deprecated. use uisetup() instead.',
> +                          DeprecationWarning)
>             try:
>                 extsetup(ui)
>             except TypeError:
> diff --git a/tests/test-extension b/tests/test-extension
> --- a/tests/test-extension
> +++ b/tests/test-extension
> @@ -73,7 +73,7 @@ echo 'foo = foo.py' >> $HGRCPATH
>  echo 'bar = bar.py' >> $HGRCPATH
>
>  # command with no output, we just want to see the extensions loaded
> -hg paths
> +hg paths 2>&1 | sed 's|.*: \(DeprecationWarning:\)|\1|'
>
>  echo 'foo = !' >> $HGRCPATH
>  echo 'bar = !' >> $HGRCPATH
> diff --git a/tests/test-extension.out b/tests/test-extension.out
> --- a/tests/test-extension.out
> +++ b/tests/test-extension.out
> @@ -16,6 +16,8 @@ uisetup called
>  reposetup called for a
>  ui == repo.ui
>  Foo
> +DeprecationWarning: extsetup() is deprecated. use uisetup() instead.
> +  DeprecationWarning)
>  1) foo imported
>  1) bar imported
>  2) foo uisetup
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>



More information about the Mercurial-devel mailing list