comparison mercurial/commands.py @ 7880:7ca2be800804

add debugcommands command: an easy to parse command + option index
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Mon, 23 Mar 2009 13:43:48 +0100
parents 553aa0cbeab6
children 553cef16031f
comparison
equal deleted inserted replaced
7879:5c4026a289a4 7880:7ca2be800804
680 lookup = repo.lookup 680 lookup = repo.lookup
681 else: 681 else:
682 raise util.Abort(_('either two or three arguments required')) 682 raise util.Abort(_('either two or three arguments required'))
683 a = r.ancestor(lookup(rev1), lookup(rev2)) 683 a = r.ancestor(lookup(rev1), lookup(rev2))
684 ui.write("%d:%s\n" % (r.rev(a), hex(a))) 684 ui.write("%d:%s\n" % (r.rev(a), hex(a)))
685
686 def debugcommands(ui, cmd='', *args):
687 for cmd, vals in util.sort(table.iteritems()):
688 cmd = cmd.split('|')[0].strip('^')
689 opts = ', '.join([i[1] for i in vals[1]])
690 ui.write('%s: %s\n' % (cmd, opts))
685 691
686 def debugcomplete(ui, cmd='', **opts): 692 def debugcomplete(ui, cmd='', **opts):
687 """returns the completion list associated with the given command""" 693 """returns the completion list associated with the given command"""
688 694
689 if opts.get('options'): 695 if opts.get('options'):
3132 _('forcibly copy over an existing managed file')), 3138 _('forcibly copy over an existing managed file')),
3133 ] + walkopts + dryrunopts, 3139 ] + walkopts + dryrunopts,
3134 _('[OPTION]... [SOURCE]... DEST')), 3140 _('[OPTION]... [SOURCE]... DEST')),
3135 "debugancestor": (debugancestor, [], _('[INDEX] REV1 REV2')), 3141 "debugancestor": (debugancestor, [], _('[INDEX] REV1 REV2')),
3136 "debugcheckstate": (debugcheckstate, []), 3142 "debugcheckstate": (debugcheckstate, []),
3143 "debugcommands": (debugcommands, [], _('[COMMAND]')),
3137 "debugcomplete": 3144 "debugcomplete":
3138 (debugcomplete, 3145 (debugcomplete,
3139 [('o', 'options', None, _('show the command options'))], 3146 [('o', 'options', None, _('show the command options'))],
3140 _('[-o] CMD')), 3147 _('[-o] CMD')),
3141 "debugdate": 3148 "debugdate":
3414 _('[-C] [-d DATE] [[-r] REV]')), 3421 _('[-C] [-d DATE] [[-r] REV]')),
3415 "verify": (verify, []), 3422 "verify": (verify, []),
3416 "version": (version_, []), 3423 "version": (version_, []),
3417 } 3424 }
3418 3425
3419 norepo = ("clone init version help debugcomplete debugdata" 3426 norepo = ("clone init version help debugcommands debugcomplete debugdata"
3420 " debugindex debugindexdot debugdate debuginstall debugfsinfo") 3427 " debugindex debugindexdot debugdate debuginstall debugfsinfo")
3421 optionalrepo = ("identify paths serve showconfig debugancestor") 3428 optionalrepo = ("identify paths serve showconfig debugancestor")