Show More
@@ -3335,7 +3335,10 b' def _performrevert(repo, parents, ctx, a' | |||
|
3335 | 3335 | if f in copied: |
|
3336 | 3336 | repo.dirstate.copy(copied[f], f) |
|
3337 | 3337 | |
|
3338 |
command |
|
|
3338 | class command(registrar.command): | |
|
3339 | def _doregister(self, func, name, *args, **kwargs): | |
|
3340 | func._deprecatedregistrar = True # flag for deprecwarn in extensions.py | |
|
3341 | return super(command, self)._doregister(func, name, *args, **kwargs) | |
|
3339 | 3342 | |
|
3340 | 3343 | # a list of (ui, repo, otherpeer, opts, missing) functions called by |
|
3341 | 3344 | # commands.outgoing. "missing" is "missing" of the result of |
@@ -121,10 +121,13 b' def _reportimporterror(ui, err, failed, ' | |||
|
121 | 121 | # attributes set by registrar.command |
|
122 | 122 | _cmdfuncattrs = ('norepo', 'optionalrepo', 'inferrepo') |
|
123 | 123 | |
|
124 | def _validatecmdtable(cmdtable): | |
|
124 | def _validatecmdtable(ui, cmdtable): | |
|
125 | 125 | """Check if extension commands have required attributes""" |
|
126 | 126 | for c, e in cmdtable.iteritems(): |
|
127 | 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 | 131 | missing = [a for a in _cmdfuncattrs if not util.safehasattr(f, a)] |
|
129 | 132 | if not missing: |
|
130 | 133 | continue |
@@ -153,7 +156,7 b' def load(ui, name, path):' | |||
|
153 | 156 | ui.warn(_('(third party extension %s requires version %s or newer ' |
|
154 | 157 | 'of Mercurial; disabling)\n') % (shortname, minver)) |
|
155 | 158 | return |
|
156 | _validatecmdtable(getattr(mod, 'cmdtable', {})) | |
|
159 | _validatecmdtable(ui, getattr(mod, 'cmdtable', {})) | |
|
157 | 160 | |
|
158 | 161 | _extensions[shortname] = mod |
|
159 | 162 | _order.append(shortname) |
@@ -1590,4 +1590,19 b' Test synopsis and docstring extending' | |||
|
1590 | 1590 | $ hg help bookmarks | grep GREPME |
|
1591 | 1591 | hg bookmarks [OPTIONS]... [NAME]... GREPME [--foo] [-x] |
|
1592 | 1592 | GREPME make sure that this is in the help! |
|
1593 | $ cd .. | |
|
1593 | 1594 | |
|
1595 | Show deprecation warning for the use of cmdutil.command | |
|
1596 | ||
|
1597 | $ cat > nonregistrar.py <<EOF | |
|
1598 | > from mercurial import cmdutil | |
|
1599 | > cmdtable = {} | |
|
1600 | > command = cmdutil.command(cmdtable) | |
|
1601 | > @command('foo', [], norepo=True) | |
|
1602 | > def foo(ui): | |
|
1603 | > pass | |
|
1604 | > EOF | |
|
1605 | ||
|
1606 | $ hg --config extensions.nonregistrar=`pwd`/nonregistrar.py version > /dev/null | |
|
1607 | devel-warn: cmdutil.command is deprecated, use registrar.command to register 'foo' | |
|
1608 | (compatibility will be dropped after Mercurial-4.6, update your code.) * (glob) |
General Comments 0
You need to be logged in to leave comments.
Login now