Mercurial > hg-stable
changeset 32415:b16cb0a27377
commands: move debugcommands and debugcomplete back to commands module
These commands depend heavily on the commands table, so it doesn't make
much sense to isolate them to debugcommands.py. This helps eliminating
the future import cycle.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 14 May 2017 16:42:16 +0900 |
parents | 04baab18d60a |
children | c942c83ac2ec |
files | mercurial/commands.py mercurial/debugcommands.py |
diffstat | 2 files changed, 36 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Sun May 14 16:19:47 2017 +0900 +++ b/mercurial/commands.py Sun May 14 16:42:16 2017 +0900 @@ -1795,6 +1795,42 @@ with repo.wlock(False): return cmdutil.copy(ui, repo, pats, opts) +@command('debugcommands', [], _('[COMMAND]'), norepo=True) +def debugcommands(ui, cmd='', *args): + """list all available commands and options""" + for cmd, vals in sorted(table.iteritems()): + cmd = cmd.split('|')[0].strip('^') + opts = ', '.join([i[1] for i in vals[1]]) + ui.write('%s: %s\n' % (cmd, opts)) + +@command('debugcomplete', + [('o', 'options', None, _('show the command options'))], + _('[-o] CMD'), + norepo=True) +def debugcomplete(ui, cmd='', **opts): + """returns the completion list associated with the given command""" + + if opts.get('options'): + options = [] + otables = [globalopts] + if cmd: + aliases, entry = cmdutil.findcmd(cmd, table, False) + otables.append(entry[1]) + for t in otables: + for o in t: + if "(DEPRECATED)" in o[3]: + continue + if o[0]: + options.append('-%s' % o[0]) + options.append('--%s' % o[1]) + ui.write("%s\n" % "\n".join(options)) + return + + cmdlist, unused_allcmds = cmdutil.findpossible(cmd, table) + if ui.verbose: + cmdlist = [' '.join(c[0]) for c in cmdlist.values()] + ui.write("%s\n" % "\n".join(sorted(cmdlist))) + @command('^diff', [('r', 'rev', [], _('revision'), _('REV')), ('c', 'change', '', _('change made by revision'), _('REV'))
--- a/mercurial/debugcommands.py Sun May 14 16:19:47 2017 +0900 +++ b/mercurial/debugcommands.py Sun May 14 16:42:16 2017 +0900 @@ -390,42 +390,6 @@ ui.write(', '.join(ui.label(e, e) for e in effects.split())) ui.write('\n') -@command('debugcommands', [], _('[COMMAND]'), norepo=True) -def debugcommands(ui, cmd='', *args): - """list all available commands and options""" - for cmd, vals in sorted(commands.table.iteritems()): - cmd = cmd.split('|')[0].strip('^') - opts = ', '.join([i[1] for i in vals[1]]) - ui.write('%s: %s\n' % (cmd, opts)) - -@command('debugcomplete', - [('o', 'options', None, _('show the command options'))], - _('[-o] CMD'), - norepo=True) -def debugcomplete(ui, cmd='', **opts): - """returns the completion list associated with the given command""" - - if opts.get('options'): - options = [] - otables = [commands.globalopts] - if cmd: - aliases, entry = cmdutil.findcmd(cmd, commands.table, False) - otables.append(entry[1]) - for t in otables: - for o in t: - if "(DEPRECATED)" in o[3]: - continue - if o[0]: - options.append('-%s' % o[0]) - options.append('--%s' % o[1]) - ui.write("%s\n" % "\n".join(options)) - return - - cmdlist, unused_allcmds = cmdutil.findpossible(cmd, commands.table) - if ui.verbose: - cmdlist = [' '.join(c[0]) for c in cmdlist.values()] - ui.write("%s\n" % "\n".join(sorted(cmdlist))) - @command('debugcreatestreamclonebundle', [], 'FILE') def debugcreatestreamclonebundle(ui, repo, fname): """create a stream clone bundle file