mercurial/help.py
changeset 42394 ad55a0a5894f
parent 42393 a84564b1a0b1
child 42450 9d31581cc44e
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')