Mercurial > hg-stable
changeset 9417:4c3fb45123e5
util, minirst: do not crash with COLUMNS=0
author | Martin Geisler <mg@lazybytes.net> |
---|---|
date | Thu, 03 Sep 2009 21:07:06 +0200 |
parents | eecbaac5ca88 |
children | a82db54bc3be |
files | mercurial/minirst.py mercurial/util.py |
diffstat | 2 files changed, 5 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/minirst.py Thu Sep 03 02:42:56 2009 +0200 +++ b/mercurial/minirst.py Thu Sep 03 21:07:06 2009 +0200 @@ -279,6 +279,8 @@ def formatblock(block, width): """Format a block according to width.""" + if width <= 0: + width = 78 indent = ' ' * block['indent'] if block['type'] == 'margin': return ''
--- a/mercurial/util.py Thu Sep 03 02:42:56 2009 +0200 +++ b/mercurial/util.py Thu Sep 03 21:07:06 2009 +0200 @@ -1274,6 +1274,9 @@ def wrap(line, hangindent, width=None): if width is None: width = termwidth() - 2 + if width <= hangindent: + # adjust for weird terminal size + width = max(78, hangindent + 1) padding = '\n' + ' ' * hangindent return padding.join(textwrap.wrap(line, width=width - hangindent))