mercurial/commands.py
changeset 11615 6dbdf5c5c5bd
parent 11557 57bdc2239535
parent 11612 0e789549271d
child 11630 0c23085f051f
equal deleted inserted replaced
11614:76bab169e151 11615:6dbdf5c5c5bd
   150         pieces = []
   150         pieces = []
   151 
   151 
   152         for f in funcmap:
   152         for f in funcmap:
   153             l = [f(n) for n, dummy in lines]
   153             l = [f(n) for n, dummy in lines]
   154             if l:
   154             if l:
   155                 ml = max(map(len, l))
   155                 sized = [(x, encoding.colwidth(x)) for x in l]
   156                 pieces.append(["%*s" % (ml, x) for x in l])
   156                 ml = max([w for x, w in sized])
       
   157                 pieces.append(["%s%s" % (' ' * (ml - w), x) for x, w in sized])
   157 
   158 
   158         if pieces:
   159         if pieces:
   159             for p, l in zip(zip(*pieces), lines):
   160             for p, l in zip(zip(*pieces), lines):
   160                 ui.write("%s: %s" % (" ".join(p), l[1]))
   161                 ui.write("%s: %s" % (" ".join(p), l[1]))
   161 
   162 
  2041                                          and _(" (default: %s)") % default
  2042                                          and _(" (default: %s)") % default
  2042                                          or "")))
  2043                                          or "")))
  2043     if multioccur:
  2044     if multioccur:
  2044         msg = _("\n[+] marked option can be specified multiple times")
  2045         msg = _("\n[+] marked option can be specified multiple times")
  2045         if ui.verbose and name != 'shortlist':
  2046         if ui.verbose and name != 'shortlist':
  2046             opt_output.append((msg, ()))
  2047             opt_output.append((msg, None))
  2047         else:
  2048         else:
  2048             opt_output.insert(-1, (msg, ()))
  2049             opt_output.insert(-1, (msg, None))
  2049 
  2050 
  2050     if not name:
  2051     if not name:
  2051         ui.write(_("\nadditional help topics:\n\n"))
  2052         ui.write(_("\nadditional help topics:\n\n"))
  2052         topics = []
  2053         topics = []
  2053         for names, header, doc in help.helptable:
  2054         for names, header, doc in help.helptable:
  2055         topics_len = max([len(s[0]) for s in topics])
  2056         topics_len = max([len(s[0]) for s in topics])
  2056         for t, desc in topics:
  2057         for t, desc in topics:
  2057             ui.write(" %-*s  %s\n" % (topics_len, t, desc))
  2058             ui.write(" %-*s  %s\n" % (topics_len, t, desc))
  2058 
  2059 
  2059     if opt_output:
  2060     if opt_output:
  2060         opts_len = max([len(line[0]) for line in opt_output if line[1]] or [0])
  2061         colwidth = encoding.colwidth
  2061         for first, second in opt_output:
  2062         # normalize: (opt or message, desc or None, width of opt)
  2062             if second:
  2063         entries = [desc and (opt, desc, colwidth(opt)) or (opt, None, 0)
  2063                 initindent = ' %-*s  ' % (opts_len, first)
  2064                    for opt, desc in opt_output]
  2064                 hangindent = ' ' * (opts_len + 3)
  2065         hanging = max([e[2] for e in entries])
  2065                 ui.write('%s\n' % (util.wrap(second,
  2066         for opt, desc, width in entries:
       
  2067             if desc:
       
  2068                 initindent = ' %s%s  ' % (opt, ' ' * (hanging - width))
       
  2069                 hangindent = ' ' * (hanging + 3)
       
  2070                 ui.write('%s\n' % (util.wrap(desc,
  2066                                              initindent=initindent,
  2071                                              initindent=initindent,
  2067                                              hangindent=hangindent)))
  2072                                              hangindent=hangindent)))
  2068             else:
  2073             else:
  2069                 ui.write("%s\n" % first)
  2074                 ui.write("%s\n" % opt)
  2070 
  2075 
  2071 def identify(ui, repo, source=None,
  2076 def identify(ui, repo, source=None,
  2072              rev=None, num=None, id=None, branch=None, tags=None):
  2077              rev=None, num=None, id=None, branch=None, tags=None):
  2073     """identify the working copy or specified revision
  2078     """identify the working copy or specified revision
  2074 
  2079 
  3762     """update working directory (or switch revisions)
  3767     """update working directory (or switch revisions)
  3763 
  3768 
  3764     Update the repository's working directory to the specified
  3769     Update the repository's working directory to the specified
  3765     changeset.
  3770     changeset.
  3766 
  3771 
  3767     If no changeset is specified, attempt to update to the head of the
  3772     If no changeset is specified, attempt to update to the tip of the
  3768     current branch. If this head is a descendant of the working
  3773     current branch. If this changeset is a descendant of the working
  3769     directory's parent, update to it, otherwise abort.
  3774     directory's parent, update to it, otherwise abort.
  3770 
  3775 
  3771     The following rules apply when the working directory contains
  3776     The following rules apply when the working directory contains
  3772     uncommitted changes:
  3777     uncommitted changes:
  3773 
  3778