comparison mercurial/commands.py @ 16783:bb446969efd4

help: inline helper function used once only
author Olav Reinert <seroton10@gmail.com>
date Tue, 22 May 2012 22:08:41 +0200
parents ba512212dab1
children e740746ea557
comparison
equal deleted inserted replaced
16782:ba512212dab1 16783:bb446969efd4
3087 Returns 0 if successful. 3087 Returns 0 if successful.
3088 """ 3088 """
3089 3089
3090 textwidth = min(ui.termwidth(), 80) - 2 3090 textwidth = min(ui.termwidth(), 80) - 2
3091 3091
3092 def addglobalopts(optlist):
3093 if ui.quiet:
3094 return []
3095
3096 if ui.verbose:
3097 optlist.append((_("global options:"), globalopts))
3098 if name == 'shortlist':
3099 optlist.append((_('use "hg help" for the full list '
3100 'of commands'), ()))
3101 else:
3102 if name == 'shortlist':
3103 msg = _('use "hg help" for the full list of commands '
3104 'or "hg -v" for details')
3105 elif name and not full:
3106 msg = _('use "hg help %s" to show the full help text') % name
3107 else:
3108 msg = _('use "hg -v help%s" to show builtin aliases and '
3109 'global options') % (name and " " + name or "")
3110 optlist.append((msg, ()))
3111
3112 def helpcmd(name): 3092 def helpcmd(name):
3113 try: 3093 try:
3114 aliases, entry = cmdutil.findcmd(name, table, strict=unknowncmd) 3094 aliases, entry = cmdutil.findcmd(name, table, strict=unknowncmd)
3115 except error.AmbiguousCommand, inst: 3095 except error.AmbiguousCommand, inst:
3116 # py3k fix: except vars can't be used outside the scope of the 3096 # py3k fix: except vars can't be used outside the scope of the
3249 topics_len = max([len(s[0]) for s in topics]) 3229 topics_len = max([len(s[0]) for s in topics])
3250 for t, desc in topics: 3230 for t, desc in topics:
3251 ui.write(" %-*s %s\n" % (topics_len, t, desc)) 3231 ui.write(" %-*s %s\n" % (topics_len, t, desc))
3252 3232
3253 optlist = [] 3233 optlist = []
3254 addglobalopts(optlist) 3234 if not ui.quiet:
3235 if ui.verbose:
3236 optlist.append((_("global options:"), globalopts))
3237 if name == 'shortlist':
3238 optlist.append((_('use "hg help" for the full list '
3239 'of commands'), ()))
3240 else:
3241 if name == 'shortlist':
3242 msg = _('use "hg help" for the full list of commands '
3243 'or "hg -v" for details')
3244 elif name and not full:
3245 msg = _('use "hg help %s" to show the full help '
3246 'text') % name
3247 else:
3248 msg = _('use "hg -v help%s" to show builtin aliases and '
3249 'global options') % (name and " " + name or "")
3250 optlist.append((msg, ()))
3251
3255 ui.write(help.opttext(optlist, textwidth, ui.verbose)) 3252 ui.write(help.opttext(optlist, textwidth, ui.verbose))
3256 3253
3257 def helptopic(name): 3254 def helptopic(name):
3258 for names, header, doc in help.helptable: 3255 for names, header, doc in help.helptable:
3259 if name in names: 3256 if name in names: