Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/debugcommands.py @ 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 |
comparison
equal
deleted
inserted
replaced
32414:04baab18d60a | 32415:b16cb0a27377 |
---|---|
388 ui.write(': ') | 388 ui.write(': ') |
389 ui.write(' ' * (max(0, width - len(label)))) | 389 ui.write(' ' * (max(0, width - len(label)))) |
390 ui.write(', '.join(ui.label(e, e) for e in effects.split())) | 390 ui.write(', '.join(ui.label(e, e) for e in effects.split())) |
391 ui.write('\n') | 391 ui.write('\n') |
392 | 392 |
393 @command('debugcommands', [], _('[COMMAND]'), norepo=True) | |
394 def debugcommands(ui, cmd='', *args): | |
395 """list all available commands and options""" | |
396 for cmd, vals in sorted(commands.table.iteritems()): | |
397 cmd = cmd.split('|')[0].strip('^') | |
398 opts = ', '.join([i[1] for i in vals[1]]) | |
399 ui.write('%s: %s\n' % (cmd, opts)) | |
400 | |
401 @command('debugcomplete', | |
402 [('o', 'options', None, _('show the command options'))], | |
403 _('[-o] CMD'), | |
404 norepo=True) | |
405 def debugcomplete(ui, cmd='', **opts): | |
406 """returns the completion list associated with the given command""" | |
407 | |
408 if opts.get('options'): | |
409 options = [] | |
410 otables = [commands.globalopts] | |
411 if cmd: | |
412 aliases, entry = cmdutil.findcmd(cmd, commands.table, False) | |
413 otables.append(entry[1]) | |
414 for t in otables: | |
415 for o in t: | |
416 if "(DEPRECATED)" in o[3]: | |
417 continue | |
418 if o[0]: | |
419 options.append('-%s' % o[0]) | |
420 options.append('--%s' % o[1]) | |
421 ui.write("%s\n" % "\n".join(options)) | |
422 return | |
423 | |
424 cmdlist, unused_allcmds = cmdutil.findpossible(cmd, commands.table) | |
425 if ui.verbose: | |
426 cmdlist = [' '.join(c[0]) for c in cmdlist.values()] | |
427 ui.write("%s\n" % "\n".join(sorted(cmdlist))) | |
428 | |
429 @command('debugcreatestreamclonebundle', [], 'FILE') | 393 @command('debugcreatestreamclonebundle', [], 'FILE') |
430 def debugcreatestreamclonebundle(ui, repo, fname): | 394 def debugcreatestreamclonebundle(ui, repo, fname): |
431 """create a stream clone bundle file | 395 """create a stream clone bundle file |
432 | 396 |
433 Stream bundles are special bundles that are essentially archives of | 397 Stream bundles are special bundles that are essentially archives of |