##// END OF EJS Templates
dispatch: show deprecation warning if command has no attributes (issue5137)...
Yuya Nishihara -
r28623:38dc3f28 default
parent child Browse files
Show More
@@ -747,7 +747,12 b' def _checkshellalias(lui, ui, args, prec'
747 747 [], {})
748 748
749 749 def _cmdattr(ui, cmd, func, attr):
750 return getattr(func, attr)
750 try:
751 return getattr(func, attr)
752 except AttributeError:
753 ui.deprecwarn("missing attribute '%s', use @command decorator "
754 "to register '%s'" % (attr, cmd), '3.8')
755 return False
751 756
752 757 _loaded = set()
753 758
@@ -1203,6 +1203,48 b' disabling in command line overlays with '
1203 1203
1204 1204 $ cd ..
1205 1205
1206 Test compatibility with extension commands that don't use @command (issue5137)
1207
1208 $ hg init deprecated
1209 $ cd deprecated
1210
1211 $ cat <<EOF > deprecatedcmd.py
1212 > def deprecatedcmd(repo, ui):
1213 > pass
1214 > cmdtable = {
1215 > 'deprecatedcmd': (deprecatedcmd, [], ''),
1216 > }
1217 > EOF
1218 $ cat <<EOF > .hg/hgrc
1219 > [extensions]
1220 > deprecatedcmd = `pwd`/deprecatedcmd.py
1221 > mq = !
1222 > hgext.mq = !
1223 > hgext/mq = !
1224 > [alias]
1225 > deprecatedalias = deprecatedcmd
1226 > EOF
1227
1228 $ hg deprecatedcmd
1229 devel-warn: missing attribute 'norepo', use @command decorator to register 'deprecatedcmd'
1230 (compatibility will be dropped after Mercurial-3.8, update your code.) at: * (glob)
1231
1232 $ hg deprecatedalias
1233 devel-warn: missing attribute 'norepo', use @command decorator to register 'deprecatedalias'
1234 (compatibility will be dropped after Mercurial-3.8, update your code.) at: * (glob)
1235
1236 no warning unless command is executed:
1237
1238 $ hg paths
1239
1240 but mq iterates over command table:
1241
1242 $ hg --config extensions.mq= paths
1243 devel-warn: missing attribute 'norepo', use @command decorator to register 'deprecatedcmd'
1244 (compatibility will be dropped after Mercurial-3.8, update your code.) at: * (glob)
1245
1246 $ cd ..
1247
1206 1248 Test synopsis and docstring extending
1207 1249
1208 1250 $ hg init exthelp
General Comments 0
You need to be logged in to leave comments. Login now