comparison 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
comparison
equal deleted inserted replaced
8937:ea798e03a32e 8938:9b8c9266c59d
6 # GNU General Public License version 2, incorporated herein by reference. 6 # GNU General Public License version 2, incorporated herein by reference.
7 7
8 from node import hex, nullid, nullrev, short 8 from node import hex, nullid, nullrev, short
9 from lock import release 9 from lock import release
10 from i18n import _, gettext 10 from i18n import _, gettext
11 import os, re, sys, textwrap, subprocess, difflib, time 11 import os, re, sys, subprocess, difflib, time
12 import hg, util, revlog, bundlerepo, extensions, copies, context, error 12 import hg, util, revlog, bundlerepo, extensions, copies, context, error
13 import patch, help, mdiff, tempfile, url, encoding 13 import patch, help, mdiff, tempfile, url, encoding
14 import archival, changegroup, cmdutil, sshserver, hbisect 14 import archival, changegroup, cmdutil, sshserver, hbisect
15 from hgweb import server 15 from hgweb import server
16 import merge as merge_ 16 import merge as merge_
1512 for f in fns: 1512 for f in fns:
1513 if ui.verbose: 1513 if ui.verbose:
1514 commands = cmds[f].replace("|",", ") 1514 commands = cmds[f].replace("|",", ")
1515 ui.write(" %s:\n %s\n"%(commands, h[f])) 1515 ui.write(" %s:\n %s\n"%(commands, h[f]))
1516 else: 1516 else:
1517 ui.write(' %-*s %s\n' % (m, f, h[f])) 1517 ui.write(' %-*s %s\n' % (m, f, util.wrap(h[f], m + 4)))
1518 1518
1519 if name != 'shortlist': 1519 if name != 'shortlist':
1520 exts, maxlength = extensions.enabled() 1520 exts, maxlength = extensions.enabled()
1521 ui.write(help.listexts(_('enabled extensions:'), exts, maxlength)) 1521 ui.write(help.listexts(_('enabled extensions:'), exts, maxlength))
1522 1522
1615 1615
1616 if opt_output: 1616 if opt_output:
1617 opts_len = max([len(line[0]) for line in opt_output if line[1]] or [0]) 1617 opts_len = max([len(line[0]) for line in opt_output if line[1]] or [0])
1618 for first, second in opt_output: 1618 for first, second in opt_output:
1619 if second: 1619 if second:
1620 # wrap descriptions at 70 characters, just like the 1620 second = util.wrap(second, opts_len + 3)
1621 # main help texts 1621 ui.write(" %-*s %s\n" % (opts_len, first, second))
1622 second = textwrap.wrap(second, width=70 - opts_len - 3)
1623 pad = '\n' + ' ' * (opts_len + 3)
1624 ui.write(" %-*s %s\n" % (opts_len, first, pad.join(second)))
1625 else: 1622 else:
1626 ui.write("%s\n" % first) 1623 ui.write("%s\n" % first)
1627 1624
1628 def identify(ui, repo, source=None, 1625 def identify(ui, repo, source=None,
1629 rev=None, num=None, id=None, branch=None, tags=None): 1626 rev=None, num=None, id=None, branch=None, tags=None):