Mercurial > hg-stable
diff mercurial/util.py @ 8938:9b8c9266c59d
commands: wrap short descriptions in 'hg help'
The code for wrapping a single line of text with a hanging indent was
duplicated in commands and help -- it's now moved to a new function
called wrap in util.
The function defaults to a line width is 78 chars, and this un-wraps
some command line flag descriptions, hence the test output changes.
author | Martin Geisler <mg@lazybytes.net> |
---|---|
date | Wed, 24 Jun 2009 19:15:58 +0200 |
parents | 7a9151bc5b37 |
children | 0001e49f1c11 9f191931c859 |
line wrap: on
line diff
--- a/mercurial/util.py Wed Jun 24 18:40:13 2009 +0200 +++ b/mercurial/util.py Wed Jun 24 19:15:58 2009 +0200 @@ -16,7 +16,7 @@ from i18n import _ import error, osutil import cStringIO, errno, re, shutil, sys, tempfile, traceback -import os, stat, time, calendar, random +import os, stat, time, calendar, random, textwrap import imp # Python compatibility @@ -1242,6 +1242,10 @@ pass return 80 +def wrap(line, hangindent, width=78): + padding = '\n' + ' ' * hangindent + return padding.join(textwrap.wrap(line, width=width - hangindent)) + def iterlines(iterator): for chunk in iterator: for line in chunk.splitlines():