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

Yuya Nishihara yuya at tcha.org
Mon Oct 12 22:59:44 UTC 2009


# 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

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



More information about the Mercurial-devel mailing list