mercurial/help.py
changeset 29974 7109d5ddeb0c
parent 29859 a1092e2d70a3
child 30024 f3c4edfd35e1
equal deleted inserted replaced
29973:4ddb05751b12 29974:7109d5ddeb0c
   356         # extension help text
   356         # extension help text
   357         try:
   357         try:
   358             mod = extensions.find(name)
   358             mod = extensions.find(name)
   359             doc = gettext(mod.__doc__) or ''
   359             doc = gettext(mod.__doc__) or ''
   360             if '\n' in doc.strip():
   360             if '\n' in doc.strip():
   361                 msg = _('(use "hg help -e %s" to show help for '
   361                 msg = _("(use 'hg help -e %s' to show help for "
   362                         'the %s extension)') % (name, name)
   362                         "the %s extension)") % (name, name)
   363                 rst.append('\n%s\n' % msg)
   363                 rst.append('\n%s\n' % msg)
   364         except KeyError:
   364         except KeyError:
   365             pass
   365             pass
   366 
   366 
   367         # options
   367         # options
   372             rst.append(optrst(_("global options"),
   372             rst.append(optrst(_("global options"),
   373                               commands.globalopts, ui.verbose))
   373                               commands.globalopts, ui.verbose))
   374 
   374 
   375         if not ui.verbose:
   375         if not ui.verbose:
   376             if not full:
   376             if not full:
   377                 rst.append(_('\n(use "hg %s -h" to show more help)\n')
   377                 rst.append(_("\n(use 'hg %s -h' to show more help)\n")
   378                            % name)
   378                            % name)
   379             elif not ui.quiet:
   379             elif not ui.quiet:
   380                 rst.append(_('\n(some details hidden, use --verbose '
   380                 rst.append(_('\n(some details hidden, use --verbose '
   381                                'to show complete help)'))
   381                                'to show complete help)'))
   382 
   382 
   448             pass
   448             pass
   449         elif ui.verbose:
   449         elif ui.verbose:
   450             rst.append('\n%s\n' % optrst(_("global options"),
   450             rst.append('\n%s\n' % optrst(_("global options"),
   451                                          commands.globalopts, ui.verbose))
   451                                          commands.globalopts, ui.verbose))
   452             if name == 'shortlist':
   452             if name == 'shortlist':
   453                 rst.append(_('\n(use "hg help" for the full list '
   453                 rst.append(_("\n(use 'hg help' for the full list "
   454                              'of commands)\n'))
   454                              "of commands)\n"))
   455         else:
   455         else:
   456             if name == 'shortlist':
   456             if name == 'shortlist':
   457                 rst.append(_('\n(use "hg help" for the full list of commands '
   457                 rst.append(_("\n(use 'hg help' for the full list of commands "
   458                              'or "hg -v" for details)\n'))
   458                              "or 'hg -v' for details)\n"))
   459             elif name and not full:
   459             elif name and not full:
   460                 rst.append(_('\n(use "hg help %s" to show the full help '
   460                 rst.append(_("\n(use 'hg help %s' to show the full help "
   461                              'text)\n') % name)
   461                              "text)\n") % name)
   462             elif name and cmds and name in cmds.keys():
   462             elif name and cmds and name in cmds.keys():
   463                 rst.append(_('\n(use "hg help -v -e %s" to show built-in '
   463                 rst.append(_("\n(use 'hg help -v -e %s' to show built-in "
   464                              'aliases and global options)\n') % name)
   464                              "aliases and global options)\n") % name)
   465             else:
   465             else:
   466                 rst.append(_('\n(use "hg help -v%s" to show built-in aliases '
   466                 rst.append(_("\n(use 'hg help -v%s' to show built-in aliases "
   467                              'and global options)\n')
   467                              "and global options)\n")
   468                            % (name and " " + name or ""))
   468                            % (name and " " + name or ""))
   469         return rst
   469         return rst
   470 
   470 
   471     def helptopic(name, subtopic=None):
   471     def helptopic(name, subtopic=None):
   472         # Look for sub-topic entry first.
   472         # Look for sub-topic entry first.
   496                          ' to show complete help)')
   496                          ' to show complete help)')
   497             indicateomitted(rst, omitted)
   497             indicateomitted(rst, omitted)
   498 
   498 
   499         try:
   499         try:
   500             cmdutil.findcmd(name, commands.table)
   500             cmdutil.findcmd(name, commands.table)
   501             rst.append(_('\nuse "hg help -c %s" to see help for '
   501             rst.append(_("\nuse 'hg help -c %s' to see help for "
   502                        'the %s command\n') % (name, name))
   502                        "the %s command\n") % (name, name))
   503         except error.UnknownCommand:
   503         except error.UnknownCommand:
   504             pass
   504             pass
   505         return rst
   505         return rst
   506 
   506 
   507     def helpext(name, subtopic=None):
   507     def helpext(name, subtopic=None):
   534             except AttributeError:
   534             except AttributeError:
   535                 ct = {}
   535                 ct = {}
   536             modcmds = set([c.partition('|')[0] for c in ct])
   536             modcmds = set([c.partition('|')[0] for c in ct])
   537             rst.extend(helplist(modcmds.__contains__))
   537             rst.extend(helplist(modcmds.__contains__))
   538         else:
   538         else:
   539             rst.append(_('(use "hg help extensions" for information on enabling'
   539             rst.append(_("(use 'hg help extensions' for information on enabling"
   540                        ' extensions)\n'))
   540                        " extensions)\n"))
   541         return rst
   541         return rst
   542 
   542 
   543     def helpextcmd(name, subtopic=None):
   543     def helpextcmd(name, subtopic=None):
   544         cmd, ext, mod = extensions.disabledcmd(ui, name,
   544         cmd, ext, mod = extensions.disabledcmd(ui, name,
   545                                                ui.configbool('ui', 'strict'))
   545                                                ui.configbool('ui', 'strict'))
   547 
   547 
   548         rst = listexts(_("'%s' is provided by the following "
   548         rst = listexts(_("'%s' is provided by the following "
   549                               "extension:") % cmd, {ext: doc}, indent=4,
   549                               "extension:") % cmd, {ext: doc}, indent=4,
   550                        showdeprecated=True)
   550                        showdeprecated=True)
   551         rst.append('\n')
   551         rst.append('\n')
   552         rst.append(_('(use "hg help extensions" for information on enabling '
   552         rst.append(_("(use 'hg help extensions' for information on enabling "
   553                    'extensions)\n'))
   553                    "extensions)\n"))
   554         return rst
   554         return rst
   555 
   555 
   556 
   556 
   557     rst = []
   557     rst = []
   558     kw = opts.get('keyword')
   558     kw = opts.get('keyword')
   573                 rst.append('%s:\n\n' % title)
   573                 rst.append('%s:\n\n' % title)
   574                 rst.extend(minirst.maketable(sorted(matches[t]), 1))
   574                 rst.extend(minirst.maketable(sorted(matches[t]), 1))
   575                 rst.append('\n')
   575                 rst.append('\n')
   576         if not rst:
   576         if not rst:
   577             msg = _('no matches')
   577             msg = _('no matches')
   578             hint = _('try "hg help" for a list of topics')
   578             hint = _("try 'hg help' for a list of topics")
   579             raise error.Abort(msg, hint=hint)
   579             raise error.Abort(msg, hint=hint)
   580     elif name and name != 'shortlist':
   580     elif name and name != 'shortlist':
   581         queries = []
   581         queries = []
   582         if unknowncmd:
   582         if unknowncmd:
   583             queries += [helpextcmd]
   583             queries += [helpextcmd]
   596         else:
   596         else:
   597             if unknowncmd:
   597             if unknowncmd:
   598                 raise error.UnknownCommand(name)
   598                 raise error.UnknownCommand(name)
   599             else:
   599             else:
   600                 msg = _('no such help topic: %s') % name
   600                 msg = _('no such help topic: %s') % name
   601                 hint = _('try "hg help --keyword %s"') % name
   601                 hint = _("try 'hg help --keyword %s'") % name
   602                 raise error.Abort(msg, hint=hint)
   602                 raise error.Abort(msg, hint=hint)
   603     else:
   603     else:
   604         # program name
   604         # program name
   605         if not ui.quiet:
   605         if not ui.quiet:
   606             rst = [_("Mercurial Distributed SCM\n"), '\n']
   606             rst = [_("Mercurial Distributed SCM\n"), '\n']