comparison 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
comparison
equal deleted inserted replaced
32342:e5fbf9687600 32343:d47d7d3bd07b
119 ui.traceback() 119 ui.traceback()
120 120
121 # attributes set by registrar.command 121 # attributes set by registrar.command
122 _cmdfuncattrs = ('norepo', 'optionalrepo', 'inferrepo') 122 _cmdfuncattrs = ('norepo', 'optionalrepo', 'inferrepo')
123 123
124 def _validatecmdtable(cmdtable): 124 def _validatecmdtable(ui, cmdtable):
125 """Check if extension commands have required attributes""" 125 """Check if extension commands have required attributes"""
126 for c, e in cmdtable.iteritems(): 126 for c, e in cmdtable.iteritems():
127 f = e[0] 127 f = e[0]
128 if getattr(f, '_deprecatedregistrar', False):
129 ui.deprecwarn("cmdutil.command is deprecated, use "
130 "registrar.command to register '%s'" % c, '4.6')
128 missing = [a for a in _cmdfuncattrs if not util.safehasattr(f, a)] 131 missing = [a for a in _cmdfuncattrs if not util.safehasattr(f, a)]
129 if not missing: 132 if not missing:
130 continue 133 continue
131 raise error.ProgrammingError( 134 raise error.ProgrammingError(
132 'missing attributes: %s' % ', '.join(missing), 135 'missing attributes: %s' % ', '.join(missing),
151 minver = getattr(mod, 'minimumhgversion', None) 154 minver = getattr(mod, 'minimumhgversion', None)
152 if minver and util.versiontuple(minver, 2) > util.versiontuple(n=2): 155 if minver and util.versiontuple(minver, 2) > util.versiontuple(n=2):
153 ui.warn(_('(third party extension %s requires version %s or newer ' 156 ui.warn(_('(third party extension %s requires version %s or newer '
154 'of Mercurial; disabling)\n') % (shortname, minver)) 157 'of Mercurial; disabling)\n') % (shortname, minver))
155 return 158 return
156 _validatecmdtable(getattr(mod, 'cmdtable', {})) 159 _validatecmdtable(ui, getattr(mod, 'cmdtable', {}))
157 160
158 _extensions[shortname] = mod 161 _extensions[shortname] = mod
159 _order.append(shortname) 162 _order.append(shortname)
160 for fn in _aftercallbacks.get(shortname, []): 163 for fn in _aftercallbacks.get(shortname, []):
161 fn(loaded=True) 164 fn(loaded=True)