changeset 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
files mercurial/commands.py mercurial/util.py
diffstat 2 files changed, 3 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Sat Oct 09 16:55:33 2010 -0500
+++ b/mercurial/commands.py	Sun Oct 10 18:02:52 2010 -0500
@@ -1949,7 +1949,7 @@
                 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 @@
             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:
--- a/mercurial/util.py	Sat Oct 09 16:55:33 2010 -0500
+++ b/mercurial/util.py	Sun Oct 10 18:02:52 2010 -0500
@@ -1313,9 +1313,7 @@
 
 #### 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