--- a/tests/autodiff.py Sun May 04 21:33:14 2014 -0700
+++ b/tests/autodiff.py Sun May 04 22:48:07 2014 -0700
@@ -1,8 +1,14 @@
# Extension dedicated to test patch.diff() upgrade modes
#
#
-from mercurial import scmutil, patch, util
+from mercurial import cmdutil, scmutil, patch, util
+cmdtable = {}
+command = cmdutil.command(cmdtable)
+
+@command('autodiff',
+ [('', 'git', '', 'git upgrade mode (yes/no/auto/warn/abort)')],
+ '[OPTION]... [FILE]...')
def autodiff(ui, repo, *pats, **opts):
diffopts = patch.diffopts(ui, opts)
git = opts.get('git', 'no')
@@ -36,11 +42,3 @@
ui.write(chunk)
for fn in sorted(brokenfiles):
ui.write(('data lost for: %s\n' % fn))
-
-cmdtable = {
- "autodiff":
- (autodiff,
- [('', 'git', '', 'git upgrade mode (yes/no/auto/warn/abort)'),
- ],
- '[OPTION]... [FILE]...'),
-}
--- a/tests/test-encoding-align.t Sun May 04 21:33:14 2014 -0700
+++ b/tests/test-encoding-align.t Sun May 04 22:48:07 2014 -0700
@@ -16,19 +16,18 @@
> f = file('l', 'w'); f.write(l); f.close()
> # instant extension to show list of options
> f = file('showoptlist.py', 'w'); f.write("""# encoding: utf-8
+ > from mercurial import cmdutil
+ > cmdtable = {}
+ > command = cmdutil.command(cmdtable)
+ >
+ > @command('showoptlist',
+ > [('s', 'opt1', '', 'short width' + ' %(s)s' * 8, '%(s)s'),
+ > ('m', 'opt2', '', 'middle width' + ' %(m)s' * 8, '%(m)s'),
+ > ('l', 'opt3', '', 'long width' + ' %(l)s' * 8, '%(l)s')],
+ > '')
> def showoptlist(ui, repo, *pats, **opts):
> '''dummy command to show option descriptions'''
> return 0
- > cmdtable = {
- > 'showoptlist':
- > (showoptlist,
- > [('s', 'opt1', '', 'short width' + ' %(s)s' * 8, '%(s)s'),
- > ('m', 'opt2', '', 'middle width' + ' %(m)s' * 8, '%(m)s'),
- > ('l', 'opt3', '', 'long width' + ' %(l)s' * 8, '%(l)s')
- > ],
- > ""
- > )
- > }
> """ % globals())
> f.close()
> EOF
--- a/tests/test-encoding-textwrap.t Sun May 04 21:33:14 2014 -0700
+++ b/tests/test-encoding-textwrap.t Sun May 04 22:48:07 2014 -0700
@@ -6,7 +6,13 @@
define commands to display help text
$ cat << EOF > show.py
+ > from mercurial import cmdutil
+ >
+ > cmdtable = {}
+ > command = cmdutil.command(cmdtable)
+ >
> # Japanese full-width characters:
+ > @command('show_full_ja', [], '')
> def show_full_ja(ui, **opts):
> u'''\u3042\u3044\u3046\u3048\u304a\u304b\u304d\u304f\u3051 \u3042\u3044\u3046\u3048\u304a\u304b\u304d\u304f\u3051 \u3042\u3044\u3046\u3048\u304a\u304b\u304d\u304f\u3051
>
@@ -16,6 +22,7 @@
> '''
>
> # Japanese half-width characters:
+ > @command('show_half_ja', [], '')
> def show_half_ja(ui, *opts):
> u'''\uff71\uff72\uff73\uff74\uff75\uff76\uff77\uff78\uff79 \uff71\uff72\uff73\uff74\uff75\uff76\uff77\uff78\uff79 \uff71\uff72\uff73\uff74\uff75\uff76\uff77\uff78\uff79 \uff71\uff72\uff73\uff74\uff75\uff76\uff77\uff78\uff79
>
@@ -25,6 +32,7 @@
> '''
>
> # Japanese ambiguous-width characters:
+ > @command('show_ambig_ja', [], '')
> def show_ambig_ja(ui, **opts):
> u'''\u03b1\u03b2\u03b3\u03b4\u03c5\u03b6\u03b7\u03b8\u25cb \u03b1\u03b2\u03b3\u03b4\u03c5\u03b6\u03b7\u03b8\u25cb \u03b1\u03b2\u03b3\u03b4\u03c5\u03b6\u03b7\u03b8\u25cb
>
@@ -34,6 +42,7 @@
> '''
>
> # Russian ambiguous-width characters:
+ > @command('show_ambig_ru', [], '')
> def show_ambig_ru(ui, **opts):
> u'''\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438
>
@@ -41,13 +50,6 @@
>
> \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438
> '''
- >
- > cmdtable = {
- > 'show_full_ja': (show_full_ja, [], ""),
- > 'show_half_ja': (show_half_ja, [], ""),
- > 'show_ambig_ja': (show_ambig_ja, [], ""),
- > 'show_ambig_ru': (show_ambig_ru, [], ""),
- > }
> EOF
"COLUMNS=60" means that there is no lines which has grater than 58 width
--- a/tests/test-extension.t Sun May 04 21:33:14 2014 -0700
+++ b/tests/test-extension.t Sun May 04 22:48:07 2014 -0700
@@ -2,7 +2,10 @@
$ cat > foobar.py <<EOF
> import os
- > from mercurial import commands
+ > from mercurial import cmdutil, commands
+ >
+ > cmdtable = {}
+ > command = cmdutil.command(cmdtable)
>
> def uisetup(ui):
> ui.write("uisetup called\\n")
@@ -11,17 +14,14 @@
> ui.write("reposetup called for %s\\n" % os.path.basename(repo.root))
> ui.write("ui %s= repo.ui\\n" % (ui == repo.ui and "=" or "!"))
>
+ > @command('foo', [], 'hg foo')
> def foo(ui, *args, **kwargs):
> ui.write("Foo\\n")
>
+ > @command('bar', [], 'hg bar')
> def bar(ui, *args, **kwargs):
> ui.write("Bar\\n")
>
- > cmdtable = {
- > "foo": (foo, [], "hg foo"),
- > "bar": (bar, [], "hg bar"),
- > }
- >
> commands.norepo += ' bar'
> EOF
$ abspath=`pwd`/foobar.py
@@ -288,21 +288,22 @@
$ cat > debugextension.py <<EOF
> '''only debugcommands
> '''
+ > from mercurial import cmdutil
+ > cmdtable = {}
+ > command = cmdutil.command(cmdtable)
+ >
+ > @command('debugfoobar', [], 'hg debugfoobar')
> def debugfoobar(ui, repo, *args, **opts):
> "yet another debug command"
> pass
>
+ > @command('foo', [], 'hg foo')
> def foo(ui, repo, *args, **opts):
> """yet another foo command
>
> This command has been DEPRECATED since forever.
> """
> pass
- >
- > cmdtable = {
- > "debugfoobar": (debugfoobar, (), "hg debugfoobar"),
- > "foo": (foo, (), "hg foo")
- > }
> EOF
$ debugpath=`pwd`/debugextension.py
$ echo "debugextension = $debugpath" >> $HGRCPATH
@@ -475,15 +476,15 @@
Test help topic with same name as extension
$ cat > multirevs.py <<EOF
- > from mercurial import commands
+ > from mercurial import cmdutil, commands
+ > cmdtable = {}
+ > command = cmdutil.command(cmdtable)
> """multirevs extension
> Big multi-line module docstring."""
+ > @command('multirevs', [], 'ARG')
> def multirevs(ui, repo, arg, *args, **opts):
> """multirevs command"""
> pass
- > cmdtable = {
- > "multirevs": (multirevs, [], 'ARG')
- > }
> commands.norepo += ' multirevs'
> EOF
$ echo "multirevs = multirevs.py" >> $HGRCPATH
@@ -532,13 +533,15 @@
$ cat > debugissue811.py <<EOF
> '''show all loaded extensions
> '''
- > from mercurial import extensions, commands
+ > from mercurial import cmdutil, commands, extensions
+ > cmdtable = {}
+ > command = cmdutil.command(cmdtable)
>
+ > @command('debugextensions', [], 'hg debugextensions')
> def debugextensions(ui):
> "yet another debug command"
> ui.write("%s\n" % '\n'.join([x for x, y in extensions.extensions()]))
>
- > cmdtable = {"debugextensions": (debugextensions, (), "hg debugextensions")}
> commands.norepo += " debugextensions"
> EOF
$ echo "debugissue811 = $debugpath" >> $HGRCPATH
--- a/tests/test-help.t Sun May 04 21:33:14 2014 -0700
+++ b/tests/test-help.t Sun May 04 22:48:07 2014 -0700
@@ -652,19 +652,20 @@
$ cat > helpext.py <<EOF
> import os
- > from mercurial import commands
+ > from mercurial import cmdutil, commands
+ >
+ > cmdtable = {}
+ > command = cmdutil.command(cmdtable)
>
+ > @command('nohelp',
+ > [('', 'longdesc', 3, 'x'*90),
+ > ('n', '', None, 'normal desc'),
+ > ('', 'newline', '', 'line1\nline2')],
+ > 'hg nohelp')
+ > @command('debugoptDEP', [('', 'dopt', None, 'option is DEPRECATED')])
> def nohelp(ui, *args, **kwargs):
> pass
>
- > cmdtable = {
- > "debugoptDEP": (nohelp, [('', 'dopt', None, 'option is DEPRECATED')],),
- > "nohelp": (nohelp, [('', 'longdesc', 3, 'x'*90),
- > ('n', '', None, 'normal desc'),
- > ('', 'newline', '', 'line1\nline2'),
- > ], "hg nohelp"),
- > }
- >
> commands.norepo += ' nohelp'
> EOF
$ echo '[extensions]' >> $HGRCPATH
--- a/tests/test-progress.t Sun May 04 21:33:14 2014 -0700
+++ b/tests/test-progress.t Sun May 04 22:48:07 2014 -0700
@@ -1,7 +1,11 @@
$ cat > loop.py <<EOF
- > from mercurial import commands
+ > from mercurial import cmdutil, commands
> import time
+ >
+ > cmdtable = {}
+ > command = cmdutil.command(cmdtable)
+ >
> class incrementingtime(object):
> def __init__(self):
> self._time = 0.0
@@ -10,6 +14,11 @@
> return self._time
> time.time = incrementingtime()
>
+ > @command('loop',
+ > [('', 'total', '', 'override for total'),
+ > ('', 'nested', False, 'show nested results'),
+ > ('', 'parallel', False, 'show parallel sets of results')],
+ > 'hg loop LOOPS')
> def loop(ui, loops, **opts):
> loops = int(loops)
> total = None
@@ -38,14 +47,6 @@
> ui.progress('loop', None, 'loop.done', 'loopnum', total)
>
> commands.norepo += " loop"
- >
- > cmdtable = {
- > "loop": (loop, [('', 'total', '', 'override for total'),
- > ('', 'nested', False, 'show nested results'),
- > ('', 'parallel', False, 'show parallel sets of results'),
- > ],
- > 'hg loop LOOPS'),
- > }
> EOF
$ cp $HGRCPATH $HGRCPATH.orig