mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 15:27:13 +03:00
util: make wrap() require a width argument
This keeps hgweb's help engine from poking at file descriptors that don't exist.
This commit is contained in:
parent
78b26c82ec
commit
a3ff3a53e2
@ -1949,7 +1949,7 @@ def help_(ui, name=None, with_version=False, unknowncmd=False):
|
||||
commands = cmds[f].replace("|",", ")
|
||||
ui.write(" %s:\n %s\n"%(commands, h[f]))
|
||||
else:
|
||||
ui.write('%s\n' % (util.wrap(h[f],
|
||||
ui.write('%s\n' % (util.wrap(h[f], textwidth,
|
||||
initindent=' %-*s ' % (m, f),
|
||||
hangindent=' ' * (m + 4))))
|
||||
|
||||
@ -2106,7 +2106,7 @@ def help_(ui, name=None, with_version=False, unknowncmd=False):
|
||||
if desc:
|
||||
initindent = ' %s%s ' % (opt, ' ' * (hanging - width))
|
||||
hangindent = ' ' * (hanging + 3)
|
||||
ui.write('%s\n' % (util.wrap(desc,
|
||||
ui.write('%s\n' % (util.wrap(desc, textwidth,
|
||||
initindent=initindent,
|
||||
hangindent=hangindent)))
|
||||
else:
|
||||
|
@ -1313,9 +1313,7 @@ class MBTextWrapper(textwrap.TextWrapper):
|
||||
|
||||
#### naming convention of above implementation follows 'textwrap' module
|
||||
|
||||
def wrap(line, width=None, initindent='', hangindent=''):
|
||||
if width is None:
|
||||
width = termwidth() - 2
|
||||
def wrap(line, width, initindent='', hangindent=''):
|
||||
maxindent = max(len(hangindent), len(initindent))
|
||||
if width <= maxindent:
|
||||
# adjust for weird terminal size
|
||||
|
Loading…
Reference in New Issue
Block a user