mercurial/commands.py
changeset 16780 d064da05590d
parent 16746 9acb5cd19162
child 16781 c0b98f436cce
equal deleted inserted replaced
16779:67bfe7f64e57 16780:d064da05590d
  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 optrst(options):
  3092     def optrst(options, verbose):
  3093         data = []
  3093         data = []
  3094         multioccur = False
  3094         multioccur = False
  3095         for option in options:
  3095         for option in options:
  3096             if len(option) == 5:
  3096             if len(option) == 5:
  3097                 shortopt, longopt, default, desc, optlabel = option
  3097                 shortopt, longopt, default, desc, optlabel = option
  3098             else:
  3098             else:
  3099                 shortopt, longopt, default, desc = option
  3099                 shortopt, longopt, default, desc = option
  3100                 optlabel = _("VALUE") # default label
  3100                 optlabel = _("VALUE") # default label
  3101 
  3101 
  3102             if _("DEPRECATED") in desc and not ui.verbose:
  3102             if _("DEPRECATED") in desc and not verbose:
  3103                 continue
  3103                 continue
  3104 
  3104 
  3105             so = ''
  3105             so = ''
  3106             if shortopt:
  3106             if shortopt:
  3107                 so = '-' + shortopt
  3107                 so = '-' + shortopt
  3123             rst += _("\n[+] marked option can be specified multiple times\n")
  3123             rst += _("\n[+] marked option can be specified multiple times\n")
  3124 
  3124 
  3125         return rst
  3125         return rst
  3126 
  3126 
  3127     # list all option lists
  3127     # list all option lists
  3128     def opttext(optlist, width):
  3128     def opttext(optlist, width, verbose):
  3129         rst = ''
  3129         rst = ''
  3130         if not optlist:
  3130         if not optlist:
  3131             return ''
  3131             return ''
  3132 
  3132 
  3133         for title, options in optlist:
  3133         for title, options in optlist:
  3134             rst += '\n%s\n' % title
  3134             rst += '\n%s\n' % title
  3135             if options:
  3135             if options:
  3136                 rst += "\n"
  3136                 rst += "\n"
  3137                 rst += optrst(options)
  3137                 rst += optrst(options, verbose)
  3138                 rst += '\n'
  3138                 rst += '\n'
  3139 
  3139 
  3140         return '\n' + minirst.format(rst, width)
  3140         return '\n' + minirst.format(rst, width)
  3141 
  3141 
  3142     def addglobalopts(optlist, aliases):
  3142     def addglobalopts(optlist, aliases):
  3221         # options
  3221         # options
  3222         if not ui.quiet and entry[1]:
  3222         if not ui.quiet and entry[1]:
  3223             rst += '\n'
  3223             rst += '\n'
  3224             rst += _("options:")
  3224             rst += _("options:")
  3225             rst += '\n\n'
  3225             rst += '\n\n'
  3226             rst += optrst(entry[1])
  3226             rst += optrst(entry[1], ui.verbose)
  3227 
  3227 
  3228         if ui.verbose:
  3228         if ui.verbose:
  3229             rst += '\n'
  3229             rst += '\n'
  3230             rst += _("global options:")
  3230             rst += _("global options:")
  3231             rst += '\n\n'
  3231             rst += '\n\n'
  3232             rst += optrst(globalopts)
  3232             rst += optrst(globalopts, ui.verbose)
  3233 
  3233 
  3234         keep = ui.verbose and ['verbose'] or []
  3234         keep = ui.verbose and ['verbose'] or []
  3235         formatted, pruned = minirst.format(rst, textwidth, keep=keep)
  3235         formatted, pruned = minirst.format(rst, textwidth, keep=keep)
  3236         ui.write(formatted)
  3236         ui.write(formatted)
  3237 
  3237 
  3302             for t, desc in topics:
  3302             for t, desc in topics:
  3303                 ui.write(" %-*s   %s\n" % (topics_len, t, desc))
  3303                 ui.write(" %-*s   %s\n" % (topics_len, t, desc))
  3304 
  3304 
  3305         optlist = []
  3305         optlist = []
  3306         addglobalopts(optlist, True)
  3306         addglobalopts(optlist, True)
  3307         ui.write(opttext(optlist, textwidth))
  3307         ui.write(opttext(optlist, textwidth, ui.verbose))
  3308 
  3308 
  3309     def helptopic(name):
  3309     def helptopic(name):
  3310         for names, header, doc in help.helptable:
  3310         for names, header, doc in help.helptable:
  3311             if name in names:
  3311             if name in names:
  3312                 break
  3312                 break