--- a/mercurial/help.py Thu Sep 10 10:48:20 2015 -0400
+++ b/mercurial/help.py Thu Sep 10 20:22:37 2015 -0400
@@ -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: