# HG changeset patch # User Martin Geisler # Date 2009-09-03 19:07:06 # Node ID 4c3fb45123e5fc756192999e9fdd00fa2e3e404d # Parent eecbaac5ca881c9c98c781243841bcc4d5648d65 util, minirst: do not crash with COLUMNS=0 diff --git a/mercurial/minirst.py b/mercurial/minirst.py --- a/mercurial/minirst.py +++ b/mercurial/minirst.py @@ -279,6 +279,8 @@ def addmargins(blocks): def formatblock(block, width): """Format a block according to width.""" + if width <= 0: + width = 78 indent = ' ' * block['indent'] if block['type'] == 'margin': return '' diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -1274,6 +1274,9 @@ def termwidth(): 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))