diff mercurial/help.py @ 27325:eadbbd14bdc1

help: fix help -c/help -e/help -k Before, hg help -c was the same as hg help, now it only shows commands. Before, hg help -e was the same as hg help, now it only shows extensions. Before, hg help -k crashed, now it shows all topics.
author timeless <timeless@mozdev.org>
date Wed, 09 Dec 2015 05:56:54 +0000
parents 5456374561a7
children c4a062d090ee
line wrap: on
line diff
--- a/mercurial/help.py	Wed Dec 09 19:09:35 2015 +0000
+++ b/mercurial/help.py	Wed Dec 09 05:56:54 2015 +0000
@@ -328,7 +328,7 @@
         return rst
 
 
-    def helplist(select=None):
+    def helplist(select=None, **opts):
         # list of commands
         if name == "shortlist":
             header = _('basic commands:\n\n')
@@ -374,7 +374,9 @@
             else:
                 rst.append(' :%s: %s\n' % (f, h[f]))
 
-        if not name:
+        ex = opts.get
+        anyopts = (ex('keyword') or not (ex('command') or ex('extension')))
+        if not name and anyopts:
             exts = listexts(_('enabled extensions:'), extensions.enabled())
             if exts:
                 rst.append('\n')
@@ -491,8 +493,8 @@
 
     rst = []
     kw = opts.get('keyword')
-    if kw:
-        matches = topicmatch(ui, name)
+    if kw or name is None and any(opts[o] for o in opts):
+        matches = topicmatch(ui, name or '')
         helpareas = []
         if opts.get('extension'):
             helpareas += [('extensions', _('Extensions'))]
@@ -539,6 +541,6 @@
         # program name
         if not ui.quiet:
             rst = [_("Mercurial Distributed SCM\n"), '\n']
-        rst.extend(helplist())
+        rst.extend(helplist(None, **opts))
 
     return ''.join(rst)