Mercurial > public > mercurial-scm > hg
comparison mercurial/util.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 | c52c629ce19e |
children | 551aa6e27929 |
comparison
equal
deleted
inserted
replaced
12697:14853ca7e11b | 12698:7aef77e74cf3 |
---|---|
1311 elif not cur_line: | 1311 elif not cur_line: |
1312 cur_line.append(reversed_chunks.pop()) | 1312 cur_line.append(reversed_chunks.pop()) |
1313 | 1313 |
1314 #### naming convention of above implementation follows 'textwrap' module | 1314 #### naming convention of above implementation follows 'textwrap' module |
1315 | 1315 |
1316 def wrap(line, width=None, initindent='', hangindent=''): | 1316 def wrap(line, width, initindent='', hangindent=''): |
1317 if width is None: | |
1318 width = termwidth() - 2 | |
1319 maxindent = max(len(hangindent), len(initindent)) | 1317 maxindent = max(len(hangindent), len(initindent)) |
1320 if width <= maxindent: | 1318 if width <= maxindent: |
1321 # adjust for weird terminal size | 1319 # adjust for weird terminal size |
1322 width = max(78, maxindent + 1) | 1320 width = max(78, maxindent + 1) |
1323 wrapper = MBTextWrapper(width=width, | 1321 wrapper = MBTextWrapper(width=width, |