comparison mercurial/help.py @ 42394:ad55a0a5894f

help: include subtopic in error message if passed Differential Revision: https://phab.mercurial-scm.org/D6442
author Nathan Goldbaum <nathan12343@gmail.com>
date Thu, 23 May 2019 11:14:32 -0400
parents a84564b1a0b1
children 9d31581cc44e
comparison
equal deleted inserted replaced
42393:a84564b1a0b1 42394:ad55a0a5894f
451 return re.sub(br'( *)%s' % re.escape(marker), sub, doc) 451 return re.sub(br'( *)%s' % re.escape(marker), sub, doc)
452 452
453 addtopichook('config', inserttweakrc) 453 addtopichook('config', inserttweakrc)
454 454
455 def help_(ui, commands, name, unknowncmd=False, full=True, subtopic=None, 455 def help_(ui, commands, name, unknowncmd=False, full=True, subtopic=None,
456 **opts): 456 fullname=None, **opts):
457 ''' 457 '''
458 Generate the help for 'name' as unformatted restructured text. If 458 Generate the help for 'name' as unformatted restructured text. If
459 'name' is None, describe the commands available. 459 'name' is None, describe the commands available.
460 ''' 460 '''
461 461
812 pass 812 pass
813 else: 813 else:
814 if unknowncmd: 814 if unknowncmd:
815 raise error.UnknownCommand(name) 815 raise error.UnknownCommand(name)
816 else: 816 else:
817 msg = _('no such help topic: %s') % name 817 if fullname:
818 hint = _("try 'hg help --keyword %s'") % name 818 formatname = fullname
819 else:
820 formatname = name
821 if subtopic:
822 hintname = subtopic
823 else:
824 hintname = name
825 msg = _('no such help topic: %s') % formatname
826 hint = _("try 'hg help --keyword %s'") % hintname
819 raise error.Abort(msg, hint=hint) 827 raise error.Abort(msg, hint=hint)
820 else: 828 else:
821 # program name 829 # program name
822 if not ui.quiet: 830 if not ui.quiet:
823 rst = [_("Mercurial Distributed SCM\n"), '\n'] 831 rst = [_("Mercurial Distributed SCM\n"), '\n']
848 856
849 textwidth = ui.configint('ui', 'textwidth') 857 textwidth = ui.configint('ui', 'textwidth')
850 termwidth = ui.termwidth() - 2 858 termwidth = ui.termwidth() - 2
851 if textwidth <= 0 or termwidth < textwidth: 859 if textwidth <= 0 or termwidth < textwidth:
852 textwidth = termwidth 860 textwidth = termwidth
853 text = help_(ui, commands, name, 861 text = help_(ui, commands, name, fullname=fullname,
854 subtopic=subtopic, unknowncmd=unknowncmd, full=full, **opts) 862 subtopic=subtopic, unknowncmd=unknowncmd, full=full, **opts)
855 863
856 blocks, pruned = minirst.parse(text, keep=keep) 864 blocks, pruned = minirst.parse(text, keep=keep)
857 if 'verbose' in pruned: 865 if 'verbose' in pruned:
858 keep.append('omitted') 866 keep.append('omitted')