# HG changeset patch # User Matt Mackall # Date 2010-10-10 23:02:52 # Node ID 7aef77e74cf3faf19ce92bacf0631be7f595ad79 # Parent 14853ca7e11b46568f7281d306ee1b542826e664 util: make wrap() require a width argument This keeps hgweb's help engine from poking at file descriptors that don't exist. diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1949,7 +1949,7 @@ def help_(ui, name=None, with_version=Fa 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=Fa 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: diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -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