# HG changeset patch # User Augie Fackler # Date 2016-11-22 02:51:23 # Node ID acd30a95998024598eea5f42c0e357d2e5b7e0a6 # Parent d1b97fc87f551ac0b4359015bf57f9cfabca5c35 dispatch: stop supporting non-use of @command We said we'd delete this after 3.8. It's time. diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -79,7 +79,6 @@ from mercurial.node import ( from mercurial import ( cmdutil, commands, - dispatch, error, extensions, hg, @@ -3588,7 +3587,7 @@ def extsetup(ui): 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) diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py --- a/mercurial/dispatch.py +++ b/mercurial/dispatch.py @@ -714,14 +714,6 @@ def _checkshellalias(lui, ui, args): 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 @@ def _dispatch(req): 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 @@ def _dispatch(req): 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] diff --git a/tests/test-extension.t b/tests/test-extension.t --- a/tests/test-extension.t +++ b/tests/test-extension.t @@ -1510,48 +1510,6 @@ disabling in command line overlays with $ cd .. -Test compatibility with extension commands that don't use @command (issue5137) - - $ hg init deprecated - $ cd deprecated - - $ cat < deprecatedcmd.py - > def deprecatedcmd(repo, ui): - > pass - > cmdtable = { - > 'deprecatedcmd': (deprecatedcmd, [], ''), - > } - > EOF - $ cat < .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