Mercurial > public > mercurial-scm > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
27324:5456374561a7 | 27325:eadbbd14bdc1 |
---|---|
326 'to show complete help)')) | 326 'to show complete help)')) |
327 | 327 |
328 return rst | 328 return rst |
329 | 329 |
330 | 330 |
331 def helplist(select=None): | 331 def helplist(select=None, **opts): |
332 # list of commands | 332 # list of commands |
333 if name == "shortlist": | 333 if name == "shortlist": |
334 header = _('basic commands:\n\n') | 334 header = _('basic commands:\n\n') |
335 elif name == "debug": | 335 elif name == "debug": |
336 header = _('debug commands (internal and unsupported):\n\n') | 336 header = _('debug commands (internal and unsupported):\n\n') |
372 commacmds = cmds[f].replace("|",", ") | 372 commacmds = cmds[f].replace("|",", ") |
373 rst.append(" :%s: %s\n" % (commacmds, h[f])) | 373 rst.append(" :%s: %s\n" % (commacmds, h[f])) |
374 else: | 374 else: |
375 rst.append(' :%s: %s\n' % (f, h[f])) | 375 rst.append(' :%s: %s\n' % (f, h[f])) |
376 | 376 |
377 if not name: | 377 ex = opts.get |
378 anyopts = (ex('keyword') or not (ex('command') or ex('extension'))) | |
379 if not name and anyopts: | |
378 exts = listexts(_('enabled extensions:'), extensions.enabled()) | 380 exts = listexts(_('enabled extensions:'), extensions.enabled()) |
379 if exts: | 381 if exts: |
380 rst.append('\n') | 382 rst.append('\n') |
381 rst.extend(exts) | 383 rst.extend(exts) |
382 | 384 |
489 return rst | 491 return rst |
490 | 492 |
491 | 493 |
492 rst = [] | 494 rst = [] |
493 kw = opts.get('keyword') | 495 kw = opts.get('keyword') |
494 if kw: | 496 if kw or name is None and any(opts[o] for o in opts): |
495 matches = topicmatch(ui, name) | 497 matches = topicmatch(ui, name or '') |
496 helpareas = [] | 498 helpareas = [] |
497 if opts.get('extension'): | 499 if opts.get('extension'): |
498 helpareas += [('extensions', _('Extensions'))] | 500 helpareas += [('extensions', _('Extensions'))] |
499 if opts.get('command'): | 501 if opts.get('command'): |
500 helpareas += [('commands', _('Commands'))] | 502 helpareas += [('commands', _('Commands'))] |
537 raise error.Abort(msg, hint=hint) | 539 raise error.Abort(msg, hint=hint) |
538 else: | 540 else: |
539 # program name | 541 # program name |
540 if not ui.quiet: | 542 if not ui.quiet: |
541 rst = [_("Mercurial Distributed SCM\n"), '\n'] | 543 rst = [_("Mercurial Distributed SCM\n"), '\n'] |
542 rst.extend(helplist()) | 544 rst.extend(helplist(None, **opts)) |
543 | 545 |
544 return ''.join(rst) | 546 return ''.join(rst) |