Mercurial > public > mercurial-scm > hg-stable
diff mercurial/commands.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 | ea798e03a32e |
children | 0405f7ccb274 |
line wrap: on
line diff
--- a/mercurial/commands.py Wed Jun 24 18:40:13 2009 +0200 +++ b/mercurial/commands.py Wed Jun 24 19:15:58 2009 +0200 @@ -8,7 +8,7 @@ from node import hex, nullid, nullrev, short from lock import release from i18n import _, gettext -import os, re, sys, textwrap, subprocess, difflib, time +import os, re, sys, subprocess, difflib, time import hg, util, revlog, bundlerepo, extensions, copies, context, error import patch, help, mdiff, tempfile, url, encoding import archival, changegroup, cmdutil, sshserver, hbisect @@ -1514,7 +1514,7 @@ commands = cmds[f].replace("|",", ") ui.write(" %s:\n %s\n"%(commands, h[f])) else: - ui.write(' %-*s %s\n' % (m, f, h[f])) + ui.write(' %-*s %s\n' % (m, f, util.wrap(h[f], m + 4))) if name != 'shortlist': exts, maxlength = extensions.enabled() @@ -1617,11 +1617,8 @@ opts_len = max([len(line[0]) for line in opt_output if line[1]] or [0]) for first, second in opt_output: if second: - # wrap descriptions at 70 characters, just like the - # main help texts - second = textwrap.wrap(second, width=70 - opts_len - 3) - pad = '\n' + ' ' * (opts_len + 3) - ui.write(" %-*s %s\n" % (opts_len, first, pad.join(second))) + second = util.wrap(second, opts_len + 3) + ui.write(" %-*s %s\n" % (opts_len, first, second)) else: ui.write("%s\n" % first)