[PATCH 2 of 2 STABLE] Consistent help text formatting (indentation)
Olav Reinert
seroton10 at gmail.com
Mon Jan 9 10:31:30 CST 2012
# HG changeset patch
# User Olav Reinert <seroton10 at gmail.com>
# Date 1326126555 -3600
# Node ID dcd680d8410b6a1b4c9f6ef67271ec4789f5e34c
# Parent c9f8671b5081abd8891dd8d78ded241ae1c491db
Consistent help text formatting (indentation)
diff -r c9f8671b5081 -r dcd680d8410b mercurial/commands.py
--- a/mercurial/commands.py Mon Jan 09 17:28:49 2012 +0100
+++ b/mercurial/commands.py Mon Jan 09 17:29:15 2012 +0100
@@ -3145,27 +3145,29 @@
ui.status(header)
fns = sorted(h)
m = max(map(len, fns))
+ topics = []
for f in fns:
if ui.verbose:
commands = cmds[f].replace("|",", ")
- ui.write(" %s:\n %s\n"%(commands, h[f]))
+ topics.append(commands+':')
+ topics.append(' '+h[f])
else:
- ui.write('%s\n' % (util.wrap(h[f], textwidth,
- initindent=' %-*s ' % (m, f),
- hangindent=' ' * (m + 4))))
+ topics.append(":%s: %s" % (f, h[f]))
+ rstopt = { 'fieldshrink':False, 'fieldwidth':13, 'definitionmargin':False }
+ ui.write(minirst.format("\n".join(topics), textwidth, 1, **rstopt))
if not name:
- text = help.listexts(_('enabled extensions:'), extensions.enabled())
- if text:
- ui.write("\n%s" % minirst.format(text, textwidth))
+ extlist = help.listexts(extensions.enabled())
+ if extlist:
+ ui.write('\n%s\n\n' % _('enabled extensions:'))
+ ui.write(minirst.format(extlist, textwidth, 1, **rstopt))
ui.write(_("\nadditional help topics:\n\n"))
topics = []
for names, header, doc in help.helptable:
- topics.append((sorted(names, key=len, reverse=True)[0], header))
- topics_len = max([len(s[0]) for s in topics])
- for t, desc in topics:
- ui.write(" %-*s %s\n" % (topics_len, t, desc))
+ topics.append(":%s: %s" % (max(names, key=len), header))
+ ui.write(minirst.format("\n".join(topics), textwidth, 1,
+ **rstopt))
optlist = []
addglobalopts(optlist, True)
@@ -3185,7 +3187,7 @@
doc = doc()
ui.write("%s\n\n" % header)
- ui.write("%s" % minirst.format(doc, textwidth, indent=4))
+ ui.write(minirst.format(doc, textwidth, indent=4))
try:
cmdutil.findcmd(name, table)
ui.write(_('\nuse "hg help -c %s" to see help for '
@@ -3227,10 +3229,9 @@
cmd, ext, mod = extensions.disabledcmd(ui, name, ui.config('ui', 'strict'))
doc = gettext(mod.__doc__).splitlines()[0]
- msg = help.listexts(_("'%s' is provided by the following "
- "extension:") % cmd, {ext: doc}, indent=4)
- ui.write(minirst.format(msg, textwidth))
- ui.write('\n')
+ ui.write(_("'%s' is provided by the following extension:") % cmd)
+ extlist = help.listexts({ext: doc})
+ ui.write('\n\n%s\n' % minirst.format(extlist, textwidth, 4))
ui.write(_('use "hg help extensions" for information on enabling '
'extensions\n'))
diff -r c9f8671b5081 -r dcd680d8410b mercurial/help.py
--- a/mercurial/help.py Mon Jan 09 17:28:49 2012 +0100
+++ b/mercurial/help.py Mon Jan 09 17:29:15 2012 +0100
@@ -10,16 +10,14 @@
import extensions, revset, fileset, templatekw, templatefilters
import util
-def listexts(header, exts, indent=1):
+def listexts(exts):
'''return a text listing of the given extensions'''
if not exts:
return ''
- maxlength = max(len(e) for e in exts)
- result = '\n%s\n\n' % header
+ result = []
for name, desc in sorted(exts.iteritems()):
- result += '%s%-*s %s\n' % (' ' * indent, maxlength + 2,
- ':%s:' % name, desc)
- return result
+ result.append(':%s: %s' % (name, desc))
+ return '\n'.join(result)
def extshelp():
doc = loaddoc('extensions')()
diff -r c9f8671b5081 -r dcd680d8410b tests/test-alias.t
--- a/tests/test-alias.t Mon Jan 09 17:28:49 2012 +0100
+++ b/tests/test-alias.t Mon Jan 09 17:29:15 2012 +0100
@@ -324,23 +324,23 @@
basic commands:
- add add the specified files on the next commit
- annotate show changeset information by line for each file
- clone make a copy of an existing repository
- commit commit the specified files or all outstanding changes
- diff diff repository (or selected files)
- export dump the header and diffs for one or more changesets
- forget forget the specified files on the next commit
- init create a new repository in the given directory
- log show revision history of entire repository or files
- merge merge working directory with another revision
- pull pull changes from the specified source
- push push changes to the specified destination
- remove remove the specified files on the next commit
- serve start stand-alone webserver
- status show changed files in the working directory
- summary summarize working directory state
- update update working directory (or switch revisions)
+ add add the specified files on the next commit
+ annotate show changeset information by line for each file
+ clone make a copy of an existing repository
+ commit commit the specified files or all outstanding changes
+ diff diff repository (or selected files)
+ export dump the header and diffs for one or more changesets
+ forget forget the specified files on the next commit
+ init create a new repository in the given directory
+ log show revision history of entire repository or files
+ merge merge working directory with another revision
+ pull pull changes from the specified source
+ push push changes to the specified destination
+ remove remove the specified files on the next commit
+ serve start stand-alone webserver
+ status show changed files in the working directory
+ summary summarize working directory state
+ update update working directory (or switch revisions)
use "hg help" for the full list of commands or "hg -v" for details
[255]
@@ -350,23 +350,23 @@
basic commands:
- add add the specified files on the next commit
- annotate show changeset information by line for each file
- clone make a copy of an existing repository
- commit commit the specified files or all outstanding changes
- diff diff repository (or selected files)
- export dump the header and diffs for one or more changesets
- forget forget the specified files on the next commit
- init create a new repository in the given directory
- log show revision history of entire repository or files
- merge merge working directory with another revision
- pull pull changes from the specified source
- push push changes to the specified destination
- remove remove the specified files on the next commit
- serve start stand-alone webserver
- status show changed files in the working directory
- summary summarize working directory state
- update update working directory (or switch revisions)
+ add add the specified files on the next commit
+ annotate show changeset information by line for each file
+ clone make a copy of an existing repository
+ commit commit the specified files or all outstanding changes
+ diff diff repository (or selected files)
+ export dump the header and diffs for one or more changesets
+ forget forget the specified files on the next commit
+ init create a new repository in the given directory
+ log show revision history of entire repository or files
+ merge merge working directory with another revision
+ pull pull changes from the specified source
+ push push changes to the specified destination
+ remove remove the specified files on the next commit
+ serve start stand-alone webserver
+ status show changed files in the working directory
+ summary summarize working directory state
+ update update working directory (or switch revisions)
use "hg help" for the full list of commands or "hg -v" for details
[255]
@@ -376,23 +376,23 @@
basic commands:
- add add the specified files on the next commit
- annotate show changeset information by line for each file
- clone make a copy of an existing repository
- commit commit the specified files or all outstanding changes
- diff diff repository (or selected files)
- export dump the header and diffs for one or more changesets
- forget forget the specified files on the next commit
- init create a new repository in the given directory
- log show revision history of entire repository or files
- merge merge working directory with another revision
- pull pull changes from the specified source
- push push changes to the specified destination
- remove remove the specified files on the next commit
- serve start stand-alone webserver
- status show changed files in the working directory
- summary summarize working directory state
- update update working directory (or switch revisions)
+ add add the specified files on the next commit
+ annotate show changeset information by line for each file
+ clone make a copy of an existing repository
+ commit commit the specified files or all outstanding changes
+ diff diff repository (or selected files)
+ export dump the header and diffs for one or more changesets
+ forget forget the specified files on the next commit
+ init create a new repository in the given directory
+ log show revision history of entire repository or files
+ merge merge working directory with another revision
+ pull pull changes from the specified source
+ push push changes to the specified destination
+ remove remove the specified files on the next commit
+ serve start stand-alone webserver
+ status show changed files in the working directory
+ summary summarize working directory state
+ update update working directory (or switch revisions)
use "hg help" for the full list of commands or "hg -v" for details
[255]
diff -r c9f8671b5081 -r dcd680d8410b tests/test-commandserver.py.out
--- a/tests/test-commandserver.py.out Mon Jan 09 17:28:49 2012 +0100
+++ b/tests/test-commandserver.py.out Mon Jan 09 17:29:15 2012 +0100
@@ -16,23 +16,23 @@
basic commands:
- add add the specified files on the next commit
- annotate show changeset information by line for each file
- clone make a copy of an existing repository
- commit commit the specified files or all outstanding changes
- diff diff repository (or selected files)
- export dump the header and diffs for one or more changesets
- forget forget the specified files on the next commit
- init create a new repository in the given directory
- log show revision history of entire repository or files
- merge merge working directory with another revision
- pull pull changes from the specified source
- push push changes to the specified destination
- remove remove the specified files on the next commit
- serve start stand-alone webserver
- status show changed files in the working directory
- summary summarize working directory state
- update update working directory (or switch revisions)
+ add add the specified files on the next commit
+ annotate show changeset information by line for each file
+ clone make a copy of an existing repository
+ commit commit the specified files or all outstanding changes
+ diff diff repository (or selected files)
+ export dump the header and diffs for one or more changesets
+ forget forget the specified files on the next commit
+ init create a new repository in the given directory
+ log show revision history of entire repository or files
+ merge merge working directory with another revision
+ pull pull changes from the specified source
+ push push changes to the specified destination
+ remove remove the specified files on the next commit
+ serve start stand-alone webserver
+ status show changed files in the working directory
+ summary summarize working directory state
+ update update working directory (or switch revisions)
use "hg help" for the full list of commands or "hg -v" for details
runcommand id --quiet
diff -r c9f8671b5081 -r dcd680d8410b tests/test-extension.t
--- a/tests/test-extension.t Mon Jan 09 17:28:49 2012 +0100
+++ b/tests/test-extension.t Mon Jan 09 17:29:15 2012 +0100
@@ -327,7 +327,7 @@
list of commands:
- extdiff use external program to diff repository (or selected files)
+ extdiff use external program to diff repository (or selected files)
use "hg -v help extdiff" to show builtin aliases and global options
diff -r c9f8671b5081 -r dcd680d8410b tests/test-help.t
--- a/tests/test-help.t Mon Jan 09 17:28:49 2012 +0100
+++ b/tests/test-help.t Mon Jan 09 17:29:15 2012 +0100
@@ -5,44 +5,44 @@
basic commands:
- add add the specified files on the next commit
- annotate show changeset information by line for each file
- clone make a copy of an existing repository
- commit commit the specified files or all outstanding changes
- diff diff repository (or selected files)
- export dump the header and diffs for one or more changesets
- forget forget the specified files on the next commit
- init create a new repository in the given directory
- log show revision history of entire repository or files
- merge merge working directory with another revision
- pull pull changes from the specified source
- push push changes to the specified destination
- remove remove the specified files on the next commit
- serve start stand-alone webserver
- status show changed files in the working directory
- summary summarize working directory state
- update update working directory (or switch revisions)
+ add add the specified files on the next commit
+ annotate show changeset information by line for each file
+ clone make a copy of an existing repository
+ commit commit the specified files or all outstanding changes
+ diff diff repository (or selected files)
+ export dump the header and diffs for one or more changesets
+ forget forget the specified files on the next commit
+ init create a new repository in the given directory
+ log show revision history of entire repository or files
+ merge merge working directory with another revision
+ pull pull changes from the specified source
+ push push changes to the specified destination
+ remove remove the specified files on the next commit
+ serve start stand-alone webserver
+ status show changed files in the working directory
+ summary summarize working directory state
+ update update working directory (or switch revisions)
use "hg help" for the full list of commands or "hg -v" for details
$ hg -q
- add add the specified files on the next commit
- annotate show changeset information by line for each file
- clone make a copy of an existing repository
- commit commit the specified files or all outstanding changes
- diff diff repository (or selected files)
- export dump the header and diffs for one or more changesets
- forget forget the specified files on the next commit
- init create a new repository in the given directory
- log show revision history of entire repository or files
- merge merge working directory with another revision
- pull pull changes from the specified source
- push push changes to the specified destination
- remove remove the specified files on the next commit
- serve start stand-alone webserver
- status show changed files in the working directory
- summary summarize working directory state
- update update working directory (or switch revisions)
+ add add the specified files on the next commit
+ annotate show changeset information by line for each file
+ clone make a copy of an existing repository
+ commit commit the specified files or all outstanding changes
+ diff diff repository (or selected files)
+ export dump the header and diffs for one or more changesets
+ forget forget the specified files on the next commit
+ init create a new repository in the given directory
+ log show revision history of entire repository or files
+ merge merge working directory with another revision
+ pull pull changes from the specified source
+ push push changes to the specified destination
+ remove remove the specified files on the next commit
+ serve start stand-alone webserver
+ status show changed files in the working directory
+ summary summarize working directory state
+ update update working directory (or switch revisions)
$ hg help
Mercurial Distributed SCM
@@ -381,8 +381,8 @@
$ hg help ad
list of commands:
- add add the specified files on the next commit
- addremove add all new files, delete all missing files
+ add add the specified files on the next commit
+ addremove add all new files, delete all missing files
use "hg -v help ad" to show builtin aliases and global options
@@ -531,23 +531,23 @@
basic commands:
- add add the specified files on the next commit
- annotate show changeset information by line for each file
- clone make a copy of an existing repository
- commit commit the specified files or all outstanding changes
- diff diff repository (or selected files)
- export dump the header and diffs for one or more changesets
- forget forget the specified files on the next commit
- init create a new repository in the given directory
- log show revision history of entire repository or files
- merge merge working directory with another revision
- pull pull changes from the specified source
- push push changes to the specified destination
- remove remove the specified files on the next commit
- serve start stand-alone webserver
- status show changed files in the working directory
- summary summarize working directory state
- update update working directory (or switch revisions)
+ add add the specified files on the next commit
+ annotate show changeset information by line for each file
+ clone make a copy of an existing repository
+ commit commit the specified files or all outstanding changes
+ diff diff repository (or selected files)
+ export dump the header and diffs for one or more changesets
+ forget forget the specified files on the next commit
+ init create a new repository in the given directory
+ log show revision history of entire repository or files
+ merge merge working directory with another revision
+ pull pull changes from the specified source
+ push push changes to the specified destination
+ remove remove the specified files on the next commit
+ serve start stand-alone webserver
+ status show changed files in the working directory
+ summary summarize working directory state
+ update update working directory (or switch revisions)
use "hg help" for the full list of commands or "hg -v" for details
[255]
@@ -558,23 +558,23 @@
basic commands:
- add add the specified files on the next commit
- annotate show changeset information by line for each file
- clone make a copy of an existing repository
- commit commit the specified files or all outstanding changes
- diff diff repository (or selected files)
- export dump the header and diffs for one or more changesets
- forget forget the specified files on the next commit
- init create a new repository in the given directory
- log show revision history of entire repository or files
- merge merge working directory with another revision
- pull pull changes from the specified source
- push push changes to the specified destination
- remove remove the specified files on the next commit
- serve start stand-alone webserver
- status show changed files in the working directory
- summary summarize working directory state
- update update working directory (or switch revisions)
+ add add the specified files on the next commit
+ annotate show changeset information by line for each file
+ clone make a copy of an existing repository
+ commit commit the specified files or all outstanding changes
+ diff diff repository (or selected files)
+ export dump the header and diffs for one or more changesets
+ forget forget the specified files on the next commit
+ init create a new repository in the given directory
+ log show revision history of entire repository or files
+ merge merge working directory with another revision
+ pull pull changes from the specified source
+ push push changes to the specified destination
+ remove remove the specified files on the next commit
+ serve start stand-alone webserver
+ status show changed files in the working directory
+ summary summarize working directory state
+ update update working directory (or switch revisions)
use "hg help" for the full list of commands or "hg -v" for details
[255]
@@ -666,7 +666,7 @@
enabled extensions:
- helpext (no help text available)
+ helpext (no help text available)
additional help topics:
@@ -699,7 +699,7 @@
list of commands:
- nohelp (no help text available)
+ nohelp (no help text available)
use "hg -v help helpext" to show builtin aliases and global options
diff -r c9f8671b5081 -r dcd680d8410b tests/test-strict.t
--- a/tests/test-strict.t Mon Jan 09 17:28:49 2012 +0100
+++ b/tests/test-strict.t Mon Jan 09 17:29:15 2012 +0100
@@ -16,23 +16,23 @@
basic commands:
- add add the specified files on the next commit
- annotate show changeset information by line for each file
- clone make a copy of an existing repository
- commit commit the specified files or all outstanding changes
- diff diff repository (or selected files)
- export dump the header and diffs for one or more changesets
- forget forget the specified files on the next commit
- init create a new repository in the given directory
- log show revision history of entire repository or files
- merge merge working directory with another revision
- pull pull changes from the specified source
- push push changes to the specified destination
- remove remove the specified files on the next commit
- serve start stand-alone webserver
- status show changed files in the working directory
- summary summarize working directory state
- update update working directory (or switch revisions)
+ add add the specified files on the next commit
+ annotate show changeset information by line for each file
+ clone make a copy of an existing repository
+ commit commit the specified files or all outstanding changes
+ diff diff repository (or selected files)
+ export dump the header and diffs for one or more changesets
+ forget forget the specified files on the next commit
+ init create a new repository in the given directory
+ log show revision history of entire repository or files
+ merge merge working directory with another revision
+ pull pull changes from the specified source
+ push push changes to the specified destination
+ remove remove the specified files on the next commit
+ serve start stand-alone webserver
+ status show changed files in the working directory
+ summary summarize working directory state
+ update update working directory (or switch revisions)
use "hg help" for the full list of commands or "hg -v" for details
[255]
More information about the Mercurial-devel
mailing list