##// END OF EJS Templates
dispatch: stop supporting non-use of @command...
Augie Fackler -
r30485:acd30a95 default
parent child Browse files
Show More
@@ -79,7 +79,6 b' from mercurial.node import ('
79 79 from mercurial import (
80 80 cmdutil,
81 81 commands,
82 dispatch,
83 82 error,
84 83 extensions,
85 84 hg,
@@ -3588,7 +3587,7 b' def extsetup(ui):'
3588 3587 for cmd, entry in cmdtable.iteritems():
3589 3588 cmd = cmdutil.parsealiases(cmd)[0]
3590 3589 func = entry[0]
3591 if dispatch._cmdattr(ui, cmd, func, 'norepo'):
3590 if func.norepo:
3592 3591 continue
3593 3592 entry = extensions.wrapcommand(cmdtable, cmd, mqcommand)
3594 3593 entry[1].extend(mqopt)
@@ -714,14 +714,6 b' def _checkshellalias(lui, ui, args):'
714 714 return lambda: runcommand(lui, None, cmd, args[:1], ui, options, d,
715 715 [], {})
716 716
717 def _cmdattr(ui, cmd, func, attr):
718 try:
719 return getattr(func, attr)
720 except AttributeError:
721 ui.deprecwarn("missing attribute '%s', use @command decorator "
722 "to register '%s'" % (attr, cmd), '3.8')
723 return False
724
725 717 _loaded = set()
726 718
727 719 # list of (objname, loadermod, loadername) tuple:
@@ -854,7 +846,7 b' def _dispatch(req):'
854 846 with profiling.maybeprofile(lui):
855 847 repo = None
856 848 cmdpats = args[:]
857 if not _cmdattr(ui, cmd, func, 'norepo'):
849 if not func.norepo:
858 850 # use the repo from the request only if we don't have -R
859 851 if not rpath and not cwd:
860 852 repo = req.repo
@@ -877,9 +869,8 b' def _dispatch(req):'
877 869 except error.RepoError:
878 870 if rpath and rpath[-1]: # invalid -R path
879 871 raise
880 if not _cmdattr(ui, cmd, func, 'optionalrepo'):
881 if (_cmdattr(ui, cmd, func, 'inferrepo') and
882 args and not path):
872 if not func.optionalrepo:
873 if func.inferrepo and args and not path:
883 874 # try to infer -R from command args
884 875 repos = map(cmdutil.findrepo, args)
885 876 guess = repos[0]
@@ -1510,48 +1510,6 b' disabling in command line overlays with '
1510 1510
1511 1511 $ cd ..
1512 1512
1513 Test compatibility with extension commands that don't use @command (issue5137)
1514
1515 $ hg init deprecated
1516 $ cd deprecated
1517
1518 $ cat <<EOF > deprecatedcmd.py
1519 > def deprecatedcmd(repo, ui):
1520 > pass
1521 > cmdtable = {
1522 > 'deprecatedcmd': (deprecatedcmd, [], ''),
1523 > }
1524 > EOF
1525 $ cat <<EOF > .hg/hgrc
1526 > [extensions]
1527 > deprecatedcmd = `pwd`/deprecatedcmd.py
1528 > mq = !
1529 > hgext.mq = !
1530 > hgext/mq = !
1531 > [alias]
1532 > deprecatedalias = deprecatedcmd
1533 > EOF
1534
1535 $ hg deprecatedcmd
1536 devel-warn: missing attribute 'norepo', use @command decorator to register 'deprecatedcmd'
1537 (compatibility will be dropped after Mercurial-3.8, update your code.) at: * (glob)
1538
1539 $ hg deprecatedalias
1540 devel-warn: missing attribute 'norepo', use @command decorator to register 'deprecatedalias'
1541 (compatibility will be dropped after Mercurial-3.8, update your code.) at: * (glob)
1542
1543 no warning unless command is executed:
1544
1545 $ hg paths
1546
1547 but mq iterates over command table:
1548
1549 $ hg --config extensions.mq= paths
1550 devel-warn: missing attribute 'norepo', use @command decorator to register 'deprecatedcmd'
1551 (compatibility will be dropped after Mercurial-3.8, update your code.) at: * (glob)
1552
1553 $ cd ..
1554
1555 1513 Test synopsis and docstring extending
1556 1514
1557 1515 $ hg init exthelp
General Comments 0
You need to be logged in to leave comments. Login now