[PATCH] help: fix help argument parsing and documentation
Augie Fackler
raf at durin42.com
Sun Sep 13 21:32:38 CDT 2015
On Thu, Sep 10, 2015 at 07:31:06PM -0500, timeless at mozdev.org wrote:
> # HG changeset patch
> # User timeless at mozdev.org
> # Date 1441930957 14400
> # Thu Sep 10 20:22:37 2015 -0400
> # Node ID 66f0610bbd099540bd0831e3bd69a19bff06494b
> # Parent ea489d94e1dc1fc3dc1dcbef1c86c18c49605ed1
> help: fix help argument parsing and documentation
Nice! Queued.
Would you have any interest in looking at a half-baked patch I've got
for adding help searching to hgweb? I keep not finding time for finishing it.
>
> support combining -c and -e
>
> previously -k was misdocumented:
> * the first line didn't mention it
> * the help half implied you could do help -k keyword topic
>
> with these changes, -k just changes the search method
>
> support -c and -e for -k searches
>
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -3942,9 +3942,9 @@
> @command('help',
> [('e', 'extension', None, _('show only help for extensions')),
> ('c', 'command', None, _('show only help for commands')),
> - ('k', 'keyword', '', _('show topics matching keyword')),
> + ('k', 'keyword', None, _('show topics matching keyword')),
> ],
> - _('[-ec] [TOPIC]'),
> + _('[-eck] [TOPIC]'),
> norepo=True)
> def help_(ui, name=None, **opts):
> """show help for a given topic or a help overview
> diff --git a/mercurial/help.py b/mercurial/help.py
> --- a/mercurial/help.py
> +++ b/mercurial/help.py
> @@ -475,11 +475,18 @@
> rst = []
> kw = opts.get('keyword')
> if kw:
> - matches = topicmatch(kw)
> - for t, title in (('topics', _('Topics')),
> + matches = topicmatch(name)
> + helpareas = []
> + if opts.get('extension'):
> + helpareas += [('extensions', _('Extensions'))]
> + if opts.get('command'):
> + helpareas += [('commands', _('Commands'))]
> + if not helpareas:
> + helpareas = [('topics', _('Topics')),
> ('commands', _('Commands')),
> ('extensions', _('Extensions')),
> - ('extensioncommands', _('Extension Commands'))):
> + ('extensioncommands', _('Extension Commands'))]
> + for t, title in helpareas:
> if matches[t]:
> rst.append('%s:\n\n' % title)
> rst.extend(minirst.maketable(sorted(matches[t]), 1))
> @@ -489,13 +496,14 @@
> hint = _('try "hg help" for a list of topics')
> raise util.Abort(msg, hint=hint)
> elif name and name != 'shortlist':
> + queries = []
> if unknowncmd:
> - queries = (helpextcmd,)
> - elif opts.get('extension'):
> - queries = (helpext,)
> - elif opts.get('command'):
> - queries = (helpcmd,)
> - else:
> + queries += [helpextcmd]
> + if opts.get('extension'):
> + queries += [helpext]
> + if opts.get('command'):
> + queries += [helpcmd]
> + if not queries:
> queries = (helptopic, helpcmd, helpext, helpextcmd)
> for f in queries:
> try:
> diff --git a/tests/test-help.t b/tests/test-help.t
> --- a/tests/test-help.t
> +++ b/tests/test-help.t
> @@ -982,6 +982,28 @@
> helphook1
> helphook2
>
> +Test -e / -c / -k combinations
> +
> + $ hg help -c progress
> + abort: no such help topic: progress
> + (try "hg help --keyword progress")
> + [255]
> + $ hg help -e progress |head -1
> + progress extension - show progress bars for some actions (DEPRECATED)
> + $ hg help -c -k dates |egrep '^(Topics|Extensions|Commands):'
> + Commands:
> + $ hg help -e -k a |egrep '^(Topics|Extensions|Commands):'
> + Extensions:
> + $ hg help -e -c -k date |egrep '^(Topics|Extensions|Commands):'
> + Extensions:
> + Commands:
> + $ hg help -c commit > /dev/null
> + $ hg help -e -c commit > /dev/null
> + $ hg help -e commit > /dev/null
> + abort: no such help topic: commit
> + (try "hg help --keyword commit")
> + [255]
> +
> Test keyword search help
>
> $ cat > prefixedname.py <<EOF
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list