# HG changeset patch # User Martin Geisler # Date 2011-05-10 12:42:53 # Node ID 005a540e9aeeb4eb54b244f9f17410818d177127 # Parent aa64a87b493d9dc012982082e892c64f6427cf5d help: add -c/--command flag to only show command help (issue2799) diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2293,6 +2293,12 @@ def help_(ui, name=None, with_version=Fa ui.write("%s\n\n" % header) ui.write("%s\n" % minirst.format(doc, textwidth, indent=4)) + try: + cmdutil.findcmd(name, table) + ui.write(_('\nuse "hg help -c %s" to see help for ' + 'the %s command\n') % (name, name)) + except error.UnknownCommand: + pass def helpext(name): try: @@ -2346,6 +2352,8 @@ def help_(ui, name=None, with_version=Fa queries = (helpextcmd,) elif opts.get('extension'): queries = (helpext,) + elif opts.get('command'): + queries = (helpcmd,) else: queries = (helptopic, helpcmd, helpext, helpextcmd) for f in queries: @@ -4720,8 +4728,9 @@ table = { ] + templateopts, _('[-ac] [-r STARTREV] [REV]...')), "help": (help_, - [('e', 'extension', None, _('show only help for extensions'))], - _('[-e] [TOPIC]')), + [('e', 'extension', None, _('show only help for extensions')), + ('c', 'command', None, _('show only help for commands'))], + _('[-ec] [TOPIC]')), "identify|id": (identify, [('r', 'rev', '', diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py --- a/mercurial/dispatch.py +++ b/mercurial/dispatch.py @@ -90,7 +90,7 @@ def _runcatch(ui, args): except error.CommandError, inst: if inst.args[0]: ui.warn(_("hg %s: %s\n") % (inst.args[0], inst.args[1])) - commands.help_(ui, inst.args[0], full=False) + commands.help_(ui, inst.args[0], full=False, command=True) else: ui.warn(_("hg: %s\n") % inst.args[1]) commands.help_(ui, 'shortlist') diff --git a/tests/test-bad-extension.t b/tests/test-bad-extension.t --- a/tests/test-bad-extension.t +++ b/tests/test-bad-extension.t @@ -10,6 +10,6 @@ $ hg -q help help *** failed to import extension badext from $TESTTMP/badext.py: bit bucket overflow *** failed to import extension badext2: No module named badext2 - hg help [-e] [TOPIC] + hg help [-ec] [TOPIC] show help for a given topic or a help overview diff --git a/tests/test-debugcomplete.t b/tests/test-debugcomplete.t --- a/tests/test-debugcomplete.t +++ b/tests/test-debugcomplete.t @@ -239,7 +239,7 @@ Show all commands + options debugwireargs: three, four, five, ssh, remotecmd, insecure grep: print0, all, text, follow, ignore-case, files-with-matches, line-number, rev, user, date, include, exclude heads: rev, topo, active, closed, style, template - help: extension + help: extension, command identify: rev, num, id, branch, tags, bookmarks import: strip, base, force, no-commit, exact, import-branch, message, logfile, date, user, similarity incoming: force, newest-first, bundle, rev, bookmarks, branch, patch, git, limit, no-merges, stat, style, template, ssh, remotecmd, insecure, subrepos diff --git a/tests/test-extension.t b/tests/test-extension.t --- a/tests/test-extension.t +++ b/tests/test-extension.t @@ -329,6 +329,59 @@ Extension module help vs command help: $ echo 'extdiff = !' >> $HGRCPATH +Test help topic with same name as extension + + $ cat > multirevs.py < from mercurial import commands + > """multirevs extension + > Big multi-line module docstring.""" + > def multirevs(ui, repo, arg, *args, **opts): + > """multirevs command""" + > pass + > cmdtable = { + > "multirevs": (multirevs, [], 'ARG') + > } + > commands.norepo += ' multirevs' + > EOF + $ echo "multirevs = multirevs.py" >> $HGRCPATH + + $ hg help multirevs + Specifying Multiple Revisions + + When Mercurial accepts more than one revision, they may be specified + individually, or provided as a topologically continuous range, separated + by the ":" character. + + The syntax of range notation is [BEGIN]:[END], where BEGIN and END are + revision identifiers. Both BEGIN and END are optional. If BEGIN is not + specified, it defaults to revision number 0. If END is not specified, it + defaults to the tip. The range ":" thus means "all revisions". + + If BEGIN is greater than END, revisions are treated in reverse order. + + A range acts as a closed interval. This means that a range of 3:5 gives 3, + 4 and 5. Similarly, a range of 9:6 gives 9, 8, 7, and 6. + + use "hg help -c multirevs" to see help for the multirevs command + + $ hg help -c multirevs + hg multirevs ARG + + multirevs command + + use "hg -v help multirevs" to show global options + + $ hg multirevs + hg multirevs: invalid arguments + hg multirevs ARG + + multirevs command + + use "hg help multirevs" to show the full help text + [255] + + $ echo "multirevs = !" >> $HGRCPATH + Issue811: Problem loading extensions twice (by site and by user) $ debugpath=`pwd`/debugissue811.py