comparison mercurial/help.py @ 26238:69da16b366ad

help: fix help argument parsing and documentation 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
author timeless@mozdev.org
date Thu, 10 Sep 2015 20:22:37 -0400
parents 3a4620ad4490
children 4799b5c4aaf4
comparison
equal deleted inserted replaced
26237:1c6f7cc52da9 26238:69da16b366ad
473 473
474 474
475 rst = [] 475 rst = []
476 kw = opts.get('keyword') 476 kw = opts.get('keyword')
477 if kw: 477 if kw:
478 matches = topicmatch(kw) 478 matches = topicmatch(name)
479 for t, title in (('topics', _('Topics')), 479 helpareas = []
480 if opts.get('extension'):
481 helpareas += [('extensions', _('Extensions'))]
482 if opts.get('command'):
483 helpareas += [('commands', _('Commands'))]
484 if not helpareas:
485 helpareas = [('topics', _('Topics')),
480 ('commands', _('Commands')), 486 ('commands', _('Commands')),
481 ('extensions', _('Extensions')), 487 ('extensions', _('Extensions')),
482 ('extensioncommands', _('Extension Commands'))): 488 ('extensioncommands', _('Extension Commands'))]
489 for t, title in helpareas:
483 if matches[t]: 490 if matches[t]:
484 rst.append('%s:\n\n' % title) 491 rst.append('%s:\n\n' % title)
485 rst.extend(minirst.maketable(sorted(matches[t]), 1)) 492 rst.extend(minirst.maketable(sorted(matches[t]), 1))
486 rst.append('\n') 493 rst.append('\n')
487 if not rst: 494 if not rst:
488 msg = _('no matches') 495 msg = _('no matches')
489 hint = _('try "hg help" for a list of topics') 496 hint = _('try "hg help" for a list of topics')
490 raise util.Abort(msg, hint=hint) 497 raise util.Abort(msg, hint=hint)
491 elif name and name != 'shortlist': 498 elif name and name != 'shortlist':
499 queries = []
492 if unknowncmd: 500 if unknowncmd:
493 queries = (helpextcmd,) 501 queries += [helpextcmd]
494 elif opts.get('extension'): 502 if opts.get('extension'):
495 queries = (helpext,) 503 queries += [helpext]
496 elif opts.get('command'): 504 if opts.get('command'):
497 queries = (helpcmd,) 505 queries += [helpcmd]
498 else: 506 if not queries:
499 queries = (helptopic, helpcmd, helpext, helpextcmd) 507 queries = (helptopic, helpcmd, helpext, helpextcmd)
500 for f in queries: 508 for f in queries:
501 try: 509 try:
502 rst = f(name) 510 rst = f(name)
503 break 511 break