comparison mercurial/commands.py @ 12698:7aef77e74cf3

util: make wrap() require a width argument This keeps hgweb's help engine from poking at file descriptors that don't exist.
author Matt Mackall <mpm@selenic.com>
date Sun, 10 Oct 2010 18:02:52 -0500
parents 14853ca7e11b
children d734b3470138
comparison
equal deleted inserted replaced
12697:14853ca7e11b 12698:7aef77e74cf3
1947 for f in fns: 1947 for f in fns:
1948 if ui.verbose: 1948 if ui.verbose:
1949 commands = cmds[f].replace("|",", ") 1949 commands = cmds[f].replace("|",", ")
1950 ui.write(" %s:\n %s\n"%(commands, h[f])) 1950 ui.write(" %s:\n %s\n"%(commands, h[f]))
1951 else: 1951 else:
1952 ui.write('%s\n' % (util.wrap(h[f], 1952 ui.write('%s\n' % (util.wrap(h[f], textwidth,
1953 initindent=' %-*s ' % (m, f), 1953 initindent=' %-*s ' % (m, f),
1954 hangindent=' ' * (m + 4)))) 1954 hangindent=' ' * (m + 4))))
1955 1955
1956 if not ui.quiet: 1956 if not ui.quiet:
1957 addglobalopts(True) 1957 addglobalopts(True)
2104 hanging = max([e[2] for e in entries]) 2104 hanging = max([e[2] for e in entries])
2105 for opt, desc, width in entries: 2105 for opt, desc, width in entries:
2106 if desc: 2106 if desc:
2107 initindent = ' %s%s ' % (opt, ' ' * (hanging - width)) 2107 initindent = ' %s%s ' % (opt, ' ' * (hanging - width))
2108 hangindent = ' ' * (hanging + 3) 2108 hangindent = ' ' * (hanging + 3)
2109 ui.write('%s\n' % (util.wrap(desc, 2109 ui.write('%s\n' % (util.wrap(desc, textwidth,
2110 initindent=initindent, 2110 initindent=initindent,
2111 hangindent=hangindent))) 2111 hangindent=hangindent)))
2112 else: 2112 else:
2113 ui.write("%s\n" % opt) 2113 ui.write("%s\n" % opt)
2114 2114