diff -r a17983680f12 -r 497deec204d1 mercurial/commands.py --- a/mercurial/commands.py Sun May 13 04:27:08 2012 -0500 +++ b/mercurial/commands.py Sun May 13 06:03:11 2012 -0500 @@ -3063,7 +3063,9 @@ @command('help', [('e', 'extension', None, _('show only help for extensions')), - ('c', 'command', None, _('show only help for commands'))], + ('c', 'command', None, _('show only help for commands')), + ('k', 'keyword', '', _('show topics matching keyword')), + ], _('[-ec] [TOPIC]')) def help_(ui, name=None, unknowncmd=False, full=True, **opts): """show help for a given topic or a help overview @@ -3309,7 +3311,7 @@ doc = doc() ui.write("%s\n\n" % header) - ui.write("%s" % minirst.format(doc, textwidth, indent=4)) + ui.write(minirst.format(doc, textwidth, indent=4)) try: cmdutil.findcmd(name, table) ui.write(_('\nuse "hg help -c %s" to see help for ' @@ -3359,6 +3361,18 @@ ui.write(_('use "hg help extensions" for information on enabling ' 'extensions\n')) + kw = opts.get('keyword') + if kw: + matches = help.topicmatch(kw) + for t, title in (('topics', _('Topics')), + ('commands', _('Commands')), + ('extensions', _('Extensions')), + ('extensioncommands', _('Extension Commands'))): + if matches[t]: + ui.write('%s:\n' % title) + ui.write(minirst.format(minirst.maketable(matches[t]))) + return + if name and name != 'shortlist': i = None if unknowncmd: