##// END OF EJS Templates
commands: wrap short descriptions in 'hg help'...
Martin Geisler -
r8938:9b8c9266 default
parent child Browse files
Show More
@@ -8,7 +8,7 b''
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
@@ -1514,7 +1514,7 b' def help_(ui, name=None, with_version=Fa'
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()
@@ -1617,11 +1617,8 b' def help_(ui, name=None, with_version=Fa'
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
@@ -5,9 +5,8 b''
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
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 import textwrap
9 from i18n import _
8 from i18n import _
10 import extensions
9 import extensions, util
11
10
12
11
13 def moduledoc(file):
12 def moduledoc(file):
@@ -46,11 +45,8 b' def listexts(header, exts, maxlength):'
46 return ''
45 return ''
47 result = '\n%s\n\n' % header
46 result = '\n%s\n\n' % header
48 for name, desc in sorted(exts.iteritems()):
47 for name, desc in sorted(exts.iteritems()):
49 # wrap desc at 70 characters, just like the main help texts
48 desc = util.wrap(desc, maxlength + 4)
50 desc = textwrap.wrap(desc, width=78 - maxlength - 4)
49 result += ' %s %s\n' % (name.ljust(maxlength), desc)
51 pad = '\n' + ' ' * (maxlength + 4)
52 result += ' %s %s\n' % (name.ljust(maxlength),
53 pad.join(desc))
54 return result
50 return result
55
51
56 def extshelp():
52 def extshelp():
@@ -16,7 +16,7 b' hide platform-specific details from the '
16 from i18n import _
16 from i18n import _
17 import error, osutil
17 import error, osutil
18 import cStringIO, errno, re, shutil, sys, tempfile, traceback
18 import cStringIO, errno, re, shutil, sys, tempfile, traceback
19 import os, stat, time, calendar, random
19 import os, stat, time, calendar, random, textwrap
20 import imp
20 import imp
21
21
22 # Python compatibility
22 # Python compatibility
@@ -1242,6 +1242,10 b' def termwidth():'
1242 pass
1242 pass
1243 return 80
1243 return 80
1244
1244
1245 def wrap(line, hangindent, width=78):
1246 padding = '\n' + ' ' * hangindent
1247 return padding.join(textwrap.wrap(line, width=width - hangindent))
1248
1245 def iterlines(iterator):
1249 def iterlines(iterator):
1246 for chunk in iterator:
1250 for chunk in iterator:
1247 for line in chunk.splitlines():
1251 for line in chunk.splitlines():
@@ -36,8 +36,7 b' enabled extensions:'
36 global options:
36 global options:
37 -R --repository repository root directory or symbolic path name
37 -R --repository repository root directory or symbolic path name
38 --cwd change working directory
38 --cwd change working directory
39 -y --noninteractive do not prompt, assume 'yes' for any required
39 -y --noninteractive do not prompt, assume 'yes' for any required answers
40 answers
41 -q --quiet suppress output
40 -q --quiet suppress output
42 -v --verbose enable additional output
41 -v --verbose enable additional output
43 --config set/override config option
42 --config set/override config option
@@ -27,10 +27,8 b' interactively select changes to commit'
27
27
28 options:
28 options:
29
29
30 -A --addremove mark new/missing files as added/removed before
30 -A --addremove mark new/missing files as added/removed before committing
31 committing
31 --close-branch mark a branch as closed, hiding it from the branch list
32 --close-branch mark a branch as closed, hiding it from the branch
33 list
34 -I --include include names matching the given patterns
32 -I --include include names matching the given patterns
35 -X --exclude exclude names matching the given patterns
33 -X --exclude exclude names matching the given patterns
36 -m --message use <text> as commit message
34 -m --message use <text> as commit message
General Comments 0
You need to be logged in to leave comments. Login now