[PATCH] add -e/--extension switch to help command to display extension help text only
Henri Wiechers
hwiechers at gmail.com
Sun Dec 13 12:00:29 UTC 2009
# HG changeset patch
# User Henri Wiechers <hwiechers at gmail.com>
# Date 1259490173 -7200
# Node ID c0c06fc4d0bff2c1b1b9a9e75ac6ea5814d2d7e6
# Parent dfc3ed37d58d921428a6a684001e4f708c445a52
add -e/--extension switch to help command to display extension help text only
Some extensions (such as attic) have commands/aliases that have the same name
as the extension itself. This means that the extension help is inaccessible
since 'hg help <extension-name>' will display the command/alias' help instead.
This patch remedies that by adding a switch that forces help to only display
the help text for extensions.
diff -r dfc3ed37d58d -r c0c06fc4d0bf mercurial/commands.py
--- a/mercurial/commands.py Sun Dec 13 11:56:22 2009 +0100
+++ b/mercurial/commands.py Sun Nov 29 12:22:53 2009 +0200
@@ -1444,7 +1444,7 @@
for n in heads:
displayer.show(repo[n])
-def help_(ui, name=None, with_version=False):
+def help_(ui, name=None, with_version=False, **opts):
"""show help for a given topic or a help overview
With no arguments, print a list of commands with short help messages.
@@ -1600,9 +1600,15 @@
modcmds = set([c.split('|', 1)[0] for c in ct])
helplist(_('list of commands:\n\n'), modcmds.__contains__)
+
if name and name != 'shortlist':
i = None
- for f in (helptopic, helpcmd, helpext):
+
+ helpfns = (helptopic, helpcmd, helpext)
+ if opts.get('extension'):
+ helpfns = (helpext,)
+
+ for f in helpfns:
try:
f(name)
i = None
@@ -3494,7 +3500,9 @@
_('show normal and closed branch heads')),
] + templateopts,
_('[-ac] [-r STARTREV] [REV]...')),
- "help": (help_, [], _('[TOPIC]')),
+ "help": (help_,
+ [('e', 'extension', None, _('show only help for extensions'))],
+ _('[-e] [TOPIC]')),
"identify|id":
(identify,
[('r', 'rev', '', _('identify the specified revision')),
diff -r dfc3ed37d58d -r c0c06fc4d0bf tests/test-bad-extension.out
--- a/tests/test-bad-extension.out Sun Dec 13 11:56:22 2009 +0100
+++ b/tests/test-bad-extension.out Sun Nov 29 12:22:53 2009 +0200
@@ -1,5 +1,5 @@
*** failed to import extension badext from .../badext.py: bit bucket overflow
*** failed to import extension badext2: No module named badext2
-hg help [TOPIC]
+hg help [-e] [TOPIC]
show help for a given topic or a help overview
diff -r dfc3ed37d58d -r c0c06fc4d0bf tests/test-debugcomplete.out
--- a/tests/test-debugcomplete.out Sun Dec 13 11:56:22 2009 +0100
+++ b/tests/test-debugcomplete.out Sun Nov 29 12:22:53 2009 +0200
@@ -207,7 +207,7 @@
debugwalk: include, exclude
grep: print0, all, follow, ignore-case, files-with-matches, line-number, rev, user, date, include, exclude
heads: rev, active, closed, style, template
-help:
+help: extension
identify: rev, num, id, branch, tags
import: strip, base, force, no-commit, exact, import-branch, message, logfile, date, user, similarity
incoming: force, newest-first, bundle, rev, patch, git, limit, no-merges, style, template, ssh, remotecmd
diff -r dfc3ed37d58d -r c0c06fc4d0bf tests/test-extension
--- a/tests/test-extension Sun Dec 13 11:56:22 2009 +0100
+++ b/tests/test-extension Sun Nov 29 12:22:53 2009 +0200
@@ -153,3 +153,24 @@
echo % show extensions
hg debugextensions
+
+echo % test limiting help to extension topics
+cat > exthelp.py <<EOF
+"""extension help text"""
+import os
+from mercurial import commands
+
+def exthelp(ui, *args, **kwargs):
+ """command help text"""
+ pass
+
+cmdtable = {
+ "exthelp": (exthelp, [], "hg exthelp"),
+}
+EOF
+exthelppath=`pwd`/exthelp.py
+echo "exthelp=$exthelppath" >> $HGRCPATH
+echo % should show help for exthelp command
+hg help exthelp
+echo % should show help for exthelp extension
+hg help -e exthelp
diff -r dfc3ed37d58d -r c0c06fc4d0bf tests/test-extension.out
--- a/tests/test-extension.out Sun Dec 13 11:56:22 2009 +0100
+++ b/tests/test-extension.out Sun Nov 29 12:22:53 2009 +0200
@@ -96,3 +96,18 @@
% show extensions
debugissue811
mq
+% test limiting help to extension topics
+% should show help for exthelp command
+hg exthelp
+
+command help text
+
+use "hg -v help exthelp" to show global options
+% should show help for exthelp extension
+exthelp extension - extension help text
+
+list of commands:
+
+ exthelp command help text
+
+use "hg -v help exthelp" to show aliases and global options
More information about the Mercurial-devel
mailing list