--- a/mercurial/commands.py Fri Oct 07 16:36:54 2011 -0500
+++ b/mercurial/commands.py Fri Oct 07 17:08:24 2011 -0500
@@ -2771,7 +2771,7 @@
rst = minirst.maketable(data, 1)
if multioccur:
- rst += _("\n[+] marked option can be specified multiple times")
+ rst += _("\n[+] marked option can be specified multiple times\n")
return rst
@@ -2782,9 +2782,11 @@
return ''
for title, options in optlist:
- rst += '\n%s\n\n' % title
- rst += optrst(options)
- rst += '\n'
+ rst += '\n%s\n' % title
+ if options:
+ rst += "\n"
+ rst += optrst(options)
+ rst += '\n'
return '\n' + minirst.format(rst, width)
@@ -2811,7 +2813,6 @@
optlist.append((msg, ()))
def helpcmd(name):
- optlist = []
try:
aliases, entry = cmdutil.findcmd(name, table, strict=unknowncmd)
except error.AmbiguousCommand, inst:
@@ -2828,18 +2829,20 @@
entry[0](ui)
return
+ rst = ""
+
# synopsis
if len(entry) > 2:
if entry[2].startswith('hg'):
- ui.write("%s\n" % entry[2])
+ rst += "%s\n" % entry[2]
else:
- ui.write('hg %s %s\n' % (aliases[0], entry[2]))
+ rst += 'hg %s %s\n' % (aliases[0], entry[2])
else:
- ui.write('hg %s\n' % aliases[0])
+ rst += 'hg %s\n' % aliases[0]
# aliases
if full and not ui.quiet and len(aliases) > 1:
- ui.write(_("\naliases: %s\n") % ', '.join(aliases[1:]))
+ rst += _("\naliases: %s\n") % ', '.join(aliases[1:])
# description
doc = gettext(entry[0].__doc__)
@@ -2852,14 +2855,7 @@
doc = _('alias for: hg %s\n\n%s') % (entry[0].definition, doc)
if ui.quiet or not full:
doc = doc.splitlines()[0]
- keep = ui.verbose and ['verbose'] or []
- formatted, pruned = minirst.format(doc, textwidth, keep=keep)
- ui.write("\n%s" % formatted)
-
- if not ui.quiet:
- # options
- if entry[1]:
- optlist.append((_("options:\n"), entry[1]))
+ rst += "\n" + doc + "\n"
# check if this command shadows a non-trivial (multi-line)
# extension help text
@@ -2869,12 +2865,30 @@
if '\n' in doc.strip():
msg = _('use "hg help -e %s" to show help for '
'the %s extension') % (name, name)
- ui.write('\n%s\n' % msg)
+ rst += '\n%s\n' % msg
except KeyError:
pass
- addglobalopts(optlist, False)
- ui.write(opttext(optlist, textwidth))
+ # options
+ if not ui.quiet and entry[1]:
+ rst += '\noptions:\n\n'
+ rst += optrst(entry[1])
+
+ if ui.verbose:
+ rst += '\nglobal options:\n\n'
+ rst += optrst(globalopts)
+
+ keep = ui.verbose and ['verbose'] or []
+ formatted, pruned = minirst.format(rst, textwidth, keep=keep)
+ ui.write(formatted)
+
+ if not ui.verbose:
+ if not full:
+ ui.write(_('\nuse "hg help %s" to show the full help text\n')
+ % name)
+ elif not ui.quiet:
+ ui.write(_('\nuse "hg -v help %s" to show more info\n') % name)
+
def helplist(select=None):
# list of commands
--- a/tests/test-alias.t Fri Oct 07 16:36:54 2011 -0500
+++ b/tests/test-alias.t Fri Oct 07 17:08:24 2011 -0500
@@ -305,7 +305,7 @@
$ hg rt foo
hg rt: invalid arguments
- hg rt
+ hg rt
alias for: hg root
--- a/tests/test-encoding-align.t Fri Oct 07 16:36:54 2011 -0500
+++ b/tests/test-encoding-align.t Fri Oct 07 17:08:24 2011 -0500
@@ -46,7 +46,7 @@
check alignment of option descriptions in help
$ hg help showoptlist
- hg showoptlist
+ hg showoptlist
dummy command to show option descriptions
--- a/tests/test-encoding-textwrap.t Fri Oct 07 16:36:54 2011 -0500
+++ b/tests/test-encoding-textwrap.t Fri Oct 07 17:08:24 2011 -0500
@@ -57,7 +57,7 @@
(1-1) display Japanese full-width characters in cp932
$ COLUMNS=60 hg --encoding cp932 --config extensions.show=./show.py help show_full_ja
- hg show_full_ja
+ hg show_full_ja
\x82\xa0\x82\xa2\x82\xa4\x82\xa6\x82\xa8\x82\xa9\x82\xab\x82\xad\x82\xaf \x82\xa0\x82\xa2\x82\xa4\x82\xa6\x82\xa8\x82\xa9\x82\xab\x82\xad\x82\xaf \x82\xa0\x82\xa2\x82\xa4\x82\xa6\x82\xa8\x82\xa9\x82\xab\x82\xad\x82\xaf (esc)
@@ -72,7 +72,7 @@
(1-2) display Japanese full-width characters in utf-8
$ COLUMNS=60 hg --encoding utf-8 --config extensions.show=./show.py help show_full_ja
- hg show_full_ja
+ hg show_full_ja
\xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88\xe3\x81\x8a\xe3\x81\x8b\xe3\x81\x8d\xe3\x81\x8f\xe3\x81\x91 \xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88\xe3\x81\x8a\xe3\x81\x8b\xe3\x81\x8d\xe3\x81\x8f\xe3\x81\x91 \xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88\xe3\x81\x8a\xe3\x81\x8b\xe3\x81\x8d\xe3\x81\x8f\xe3\x81\x91 (esc)
@@ -88,7 +88,7 @@
(1-3) display Japanese half-width characters in cp932
$ COLUMNS=60 hg --encoding cp932 --config extensions.show=./show.py help show_half_ja
- hg show_half_ja
+ hg show_half_ja
\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9 \xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9 \xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9 \xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9 (esc)
@@ -103,7 +103,7 @@
(1-4) display Japanese half-width characters in utf-8
$ COLUMNS=60 hg --encoding utf-8 --config extensions.show=./show.py help show_half_ja
- hg show_half_ja
+ hg show_half_ja
\xef\xbd\xb1\xef\xbd\xb2\xef\xbd\xb3\xef\xbd\xb4\xef\xbd\xb5\xef\xbd\xb6\xef\xbd\xb7\xef\xbd\xb8\xef\xbd\xb9 \xef\xbd\xb1\xef\xbd\xb2\xef\xbd\xb3\xef\xbd\xb4\xef\xbd\xb5\xef\xbd\xb6\xef\xbd\xb7\xef\xbd\xb8\xef\xbd\xb9 \xef\xbd\xb1\xef\xbd\xb2\xef\xbd\xb3\xef\xbd\xb4\xef\xbd\xb5\xef\xbd\xb6\xef\xbd\xb7\xef\xbd\xb8\xef\xbd\xb9 \xef\xbd\xb1\xef\xbd\xb2\xef\xbd\xb3\xef\xbd\xb4\xef\xbd\xb5\xef\xbd\xb6\xef\xbd\xb7\xef\xbd\xb8\xef\xbd\xb9 (esc)
@@ -124,7 +124,7 @@
(2-1-1) display Japanese ambiguous-width characters in cp932
$ COLUMNS=60 hg --encoding cp932 --config extensions.show=./show.py help show_ambig_ja
- hg show_ambig_ja
+ hg show_ambig_ja
\x83\xbf\x83\xc0\x83\xc1\x83\xc2\x83\xd2\x83\xc4\x83\xc5\x83\xc6\x81\x9b \x83\xbf\x83\xc0\x83\xc1\x83\xc2\x83\xd2\x83\xc4\x83\xc5\x83\xc6\x81\x9b \x83\xbf\x83\xc0\x83\xc1\x83\xc2\x83\xd2\x83\xc4\x83\xc5\x83\xc6\x81\x9b (esc)
@@ -139,7 +139,7 @@
(2-1-2) display Japanese ambiguous-width characters in utf-8
$ COLUMNS=60 hg --encoding utf-8 --config extensions.show=./show.py help show_ambig_ja
- hg show_ambig_ja
+ hg show_ambig_ja
\xce\xb1\xce\xb2\xce\xb3\xce\xb4\xcf\x85\xce\xb6\xce\xb7\xce\xb8\xe2\x97\x8b \xce\xb1\xce\xb2\xce\xb3\xce\xb4\xcf\x85\xce\xb6\xce\xb7\xce\xb8\xe2\x97\x8b \xce\xb1\xce\xb2\xce\xb3\xce\xb4\xcf\x85\xce\xb6\xce\xb7\xce\xb8\xe2\x97\x8b (esc)
@@ -154,7 +154,7 @@
(2-1-3) display Russian ambiguous-width characters in cp1251
$ COLUMNS=60 hg --encoding cp1251 --config extensions.show=./show.py help show_ambig_ru
- hg show_ambig_ru
+ hg show_ambig_ru
\xcd\xe0\xf1\xf2\xf0\xee\xe9\xea\xe8 \xcd\xe0\xf1\xf2\xf0\xee\xe9\xea\xe8 \xcd\xe0\xf1\xf2\xf0\xee\xe9\xea\xe8 \xcd\xe0\xf1\xf2\xf0\xee\xe9\xea\xe8 \xcd\xe0\xf1\xf2\xf0\xee\xe9\xea\xe8 (esc)
@@ -169,7 +169,7 @@
(2-1-4) display Russian ambiguous-width characters in utf-8
$ COLUMNS=60 hg --encoding utf-8 --config extensions.show=./show.py help show_ambig_ru
- hg show_ambig_ru
+ hg show_ambig_ru
\xd0\x9d\xd0\xb0\xd1\x81\xd1\x82\xd1\x80\xd0\xbe\xd0\xb9\xd0\xba\xd0\xb8 \xd0\x9d\xd0\xb0\xd1\x81\xd1\x82\xd1\x80\xd0\xbe\xd0\xb9\xd0\xba\xd0\xb8 \xd0\x9d\xd0\xb0\xd1\x81\xd1\x82\xd1\x80\xd0\xbe\xd0\xb9\xd0\xba\xd0\xb8 \xd0\x9d\xd0\xb0\xd1\x81\xd1\x82\xd1\x80\xd0\xbe\xd0\xb9\xd0\xba\xd0\xb8 \xd0\x9d\xd0\xb0\xd1\x81\xd1\x82\xd1\x80\xd0\xbe\xd0\xb9\xd0\xba\xd0\xb8 (esc)
@@ -187,7 +187,7 @@
(2-2-1) display Japanese ambiguous-width characters in cp932
$ COLUMNS=60 HGENCODINGAMBIGUOUS=wide hg --encoding cp932 --config extensions.show=./show.py help show_ambig_ja
- hg show_ambig_ja
+ hg show_ambig_ja
\x83\xbf\x83\xc0\x83\xc1\x83\xc2\x83\xd2\x83\xc4\x83\xc5\x83\xc6\x81\x9b \x83\xbf\x83\xc0\x83\xc1\x83\xc2\x83\xd2\x83\xc4\x83\xc5\x83\xc6\x81\x9b \x83\xbf\x83\xc0\x83\xc1\x83\xc2\x83\xd2\x83\xc4\x83\xc5\x83\xc6\x81\x9b (esc)
@@ -205,7 +205,7 @@
(2-2-2) display Japanese ambiguous-width characters in utf-8
$ COLUMNS=60 HGENCODINGAMBIGUOUS=wide hg --encoding utf-8 --config extensions.show=./show.py help show_ambig_ja
- hg show_ambig_ja
+ hg show_ambig_ja
\xce\xb1\xce\xb2\xce\xb3\xce\xb4\xcf\x85\xce\xb6\xce\xb7\xce\xb8\xe2\x97\x8b \xce\xb1\xce\xb2\xce\xb3\xce\xb4\xcf\x85\xce\xb6\xce\xb7\xce\xb8\xe2\x97\x8b \xce\xb1\xce\xb2\xce\xb3\xce\xb4\xcf\x85\xce\xb6\xce\xb7\xce\xb8\xe2\x97\x8b (esc)
@@ -223,7 +223,7 @@
(2-2-3) display Russian ambiguous-width characters in cp1251
$ COLUMNS=60 HGENCODINGAMBIGUOUS=wide hg --encoding cp1251 --config extensions.show=./show.py help show_ambig_ru
- hg show_ambig_ru
+ hg show_ambig_ru
\xcd\xe0\xf1\xf2\xf0\xee\xe9\xea\xe8 \xcd\xe0\xf1\xf2\xf0\xee\xe9\xea\xe8 \xcd\xe0\xf1\xf2\xf0\xee\xe9\xea\xe8 (esc)
\xcd\xe0\xf1\xf2\xf0\xee\xe9\xea\xe8 \xcd\xe0\xf1\xf2\xf0\xee\xe9\xea\xe8 (esc)
@@ -241,7 +241,7 @@
(2-2-4) display Russian ambiguous-width charactes in utf-8
$ COLUMNS=60 HGENCODINGAMBIGUOUS=wide hg --encoding utf-8 --config extensions.show=./show.py help show_ambig_ru
- hg show_ambig_ru
+ hg show_ambig_ru
\xd0\x9d\xd0\xb0\xd1\x81\xd1\x82\xd1\x80\xd0\xbe\xd0\xb9\xd0\xba\xd0\xb8 \xd0\x9d\xd0\xb0\xd1\x81\xd1\x82\xd1\x80\xd0\xbe\xd0\xb9\xd0\xba\xd0\xb8 \xd0\x9d\xd0\xb0\xd1\x81\xd1\x82\xd1\x80\xd0\xbe\xd0\xb9\xd0\xba\xd0\xb8 (esc)
\xd0\x9d\xd0\xb0\xd1\x81\xd1\x82\xd1\x80\xd0\xbe\xd0\xb9\xd0\xba\xd0\xb8 \xd0\x9d\xd0\xb0\xd1\x81\xd1\x82\xd1\x80\xd0\xbe\xd0\xb9\xd0\xba\xd0\xb8 (esc)