[PATCH 3 of 7] help: format topic help using RST

Olav Reinert seroton10 at gmail.com
Sat May 26 10:43:48 CDT 2012


# HG changeset patch
# User Olav Reinert <seroton10 at gmail.com>
# Date 1337888432 -7200
# Node ID 2b190972e8ac03f238c4169962691a9cae67f684
# Parent  25fccf8fd755f30c3d3347d135f37b097e10042c
help: format topic help using RST

diff -r 25fccf8fd755 -r 2b190972e8ac mercurial/commands.py
--- a/mercurial/commands.py	Wed May 23 23:42:31 2012 +0200
+++ b/mercurial/commands.py	Thu May 24 21:40:32 2012 +0200
@@ -3268,20 +3268,20 @@
         else:
             raise error.UnknownCommand(name)
 
+        rst = ["%s\n" % header]
         # description
         if not doc:
-            doc = _("(no help text available)")
+            rst.append("    %s" % _("(no help text available)"))
         if util.safehasattr(doc, '__call__'):
-            doc = doc()
-
-        ui.write("%s\n\n" % header)
-        ui.write(minirst.format(doc, textwidth, indent=4))
+            rst.extend(map(lambda l: "    %s" % l, doc().splitlines()))
+
         try:
             cmdutil.findcmd(name, table)
-            ui.write(_('\nuse "hg help -c %s" to see help for '
+            rst.append(_('\nuse "hg help -c %s" to see help for '
                        'the %s command\n') % (name, name))
         except error.UnknownCommand:
             pass
+        ui.write(minirst.format('\n'.join(rst), textwidth))
 
     def helpext(name):
         try:


More information about the Mercurial-devel mailing list