diff tests/test-extension.t @ 28623:38dc3f28f478

dispatch: show deprecation warning if command has no attributes (issue5137) norepo/optionalrepo/inferrepo were removed by aa73d6a5d9ea, which would be significant API change. This patch tries to avoid crash even if ancient third-party extensions are enabled.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 09 Jan 2016 22:46:26 +0900
parents 6fb1d3c936d2
children a3e5e1fb257c
line wrap: on
line diff
--- a/tests/test-extension.t	Mon Mar 14 00:14:43 2016 +0900
+++ b/tests/test-extension.t	Sat Jan 09 22:46:26 2016 +0900
@@ -1203,6 +1203,48 @@
 
   $ cd ..
 
+Test compatibility with extension commands that don't use @command (issue5137)
+
+  $ hg init deprecated
+  $ cd deprecated
+
+  $ cat <<EOF > deprecatedcmd.py
+  > def deprecatedcmd(repo, ui):
+  >     pass
+  > cmdtable = {
+  >     'deprecatedcmd': (deprecatedcmd, [], ''),
+  > }
+  > EOF
+  $ cat <<EOF > .hg/hgrc
+  > [extensions]
+  > deprecatedcmd = `pwd`/deprecatedcmd.py
+  > mq = !
+  > hgext.mq = !
+  > hgext/mq = !
+  > [alias]
+  > deprecatedalias = deprecatedcmd
+  > EOF
+
+  $ hg deprecatedcmd
+  devel-warn: missing attribute 'norepo', use @command decorator to register 'deprecatedcmd'
+  (compatibility will be dropped after Mercurial-3.8, update your code.) at: * (glob)
+
+  $ hg deprecatedalias
+  devel-warn: missing attribute 'norepo', use @command decorator to register 'deprecatedalias'
+  (compatibility will be dropped after Mercurial-3.8, update your code.) at: * (glob)
+
+ no warning unless command is executed:
+
+  $ hg paths
+
+ but mq iterates over command table:
+
+  $ hg --config extensions.mq= paths
+  devel-warn: missing attribute 'norepo', use @command decorator to register 'deprecatedcmd'
+  (compatibility will be dropped after Mercurial-3.8, update your code.) at: * (glob)
+
+  $ cd ..
+
 Test synopsis and docstring extending
 
   $ hg init exthelp