changeset 30494:acd30a959980

dispatch: stop supporting non-use of @command We said we'd delete this after 3.8. It's time.
author Augie Fackler <augie@google.com>
date Mon, 21 Nov 2016 21:51:23 -0500
parents d1b97fc87f55
children d6f3877b72c7
files hgext/mq.py mercurial/dispatch.py tests/test-extension.t
diffstat 3 files changed, 4 insertions(+), 56 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Mon Nov 21 20:12:51 2016 -0800
+++ b/hgext/mq.py	Mon Nov 21 21:51:23 2016 -0500
@@ -79,7 +79,6 @@
 from mercurial import (
     cmdutil,
     commands,
-    dispatch,
     error,
     extensions,
     hg,
@@ -3588,7 +3587,7 @@
         for cmd, entry in cmdtable.iteritems():
             cmd = cmdutil.parsealiases(cmd)[0]
             func = entry[0]
-            if dispatch._cmdattr(ui, cmd, func, 'norepo'):
+            if func.norepo:
                 continue
             entry = extensions.wrapcommand(cmdtable, cmd, mqcommand)
             entry[1].extend(mqopt)
--- a/mercurial/dispatch.py	Mon Nov 21 20:12:51 2016 -0800
+++ b/mercurial/dispatch.py	Mon Nov 21 21:51:23 2016 -0500
@@ -714,14 +714,6 @@
         return lambda: runcommand(lui, None, cmd, args[:1], ui, options, d,
                                   [], {})
 
-def _cmdattr(ui, cmd, func, attr):
-    try:
-        return getattr(func, attr)
-    except AttributeError:
-        ui.deprecwarn("missing attribute '%s', use @command decorator "
-                      "to register '%s'" % (attr, cmd), '3.8')
-        return False
-
 _loaded = set()
 
 # list of (objname, loadermod, loadername) tuple:
@@ -854,7 +846,7 @@
     with profiling.maybeprofile(lui):
         repo = None
         cmdpats = args[:]
-        if not _cmdattr(ui, cmd, func, 'norepo'):
+        if not func.norepo:
             # use the repo from the request only if we don't have -R
             if not rpath and not cwd:
                 repo = req.repo
@@ -877,9 +869,8 @@
                 except error.RepoError:
                     if rpath and rpath[-1]: # invalid -R path
                         raise
-                    if not _cmdattr(ui, cmd, func, 'optionalrepo'):
-                        if (_cmdattr(ui, cmd, func, 'inferrepo') and
-                            args and not path):
+                    if not func.optionalrepo:
+                        if func.inferrepo and args and not path:
                             # try to infer -R from command args
                             repos = map(cmdutil.findrepo, args)
                             guess = repos[0]
--- a/tests/test-extension.t	Mon Nov 21 20:12:51 2016 -0800
+++ b/tests/test-extension.t	Mon Nov 21 21:51:23 2016 -0500
@@ -1510,48 +1510,6 @@
 
   $ 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