diff mercurial/extensions.py @ 32343:d47d7d3bd07b

extensions: show deprecation warning for the use of cmdutil.command Since this is a fundamental API for extensions, we set 1-year period until actually removing it.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 09 Jan 2016 23:24:52 +0900
parents e5fbf9687600
children 9a3e88d4a030
line wrap: on
line diff
--- a/mercurial/extensions.py	Sat May 13 15:41:50 2017 +0900
+++ b/mercurial/extensions.py	Sat Jan 09 23:24:52 2016 +0900
@@ -121,10 +121,13 @@
 # attributes set by registrar.command
 _cmdfuncattrs = ('norepo', 'optionalrepo', 'inferrepo')
 
-def _validatecmdtable(cmdtable):
+def _validatecmdtable(ui, cmdtable):
     """Check if extension commands have required attributes"""
     for c, e in cmdtable.iteritems():
         f = e[0]
+        if getattr(f, '_deprecatedregistrar', False):
+            ui.deprecwarn("cmdutil.command is deprecated, use "
+                          "registrar.command to register '%s'" % c, '4.6')
         missing = [a for a in _cmdfuncattrs if not util.safehasattr(f, a)]
         if not missing:
             continue
@@ -153,7 +156,7 @@
         ui.warn(_('(third party extension %s requires version %s or newer '
                   'of Mercurial; disabling)\n') % (shortname, minver))
         return
-    _validatecmdtable(getattr(mod, 'cmdtable', {}))
+    _validatecmdtable(ui, getattr(mod, 'cmdtable', {}))
 
     _extensions[shortname] = mod
     _order.append(shortname)