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))