diff mercurial/commands.py @ 22587:c3c3dd31fe1c

help: basic support for showing only specified topic sections For instance, 'hg help config.files' will show only the Files section.
author Matt Mackall <mpm@selenic.com>
date Tue, 30 Sep 2014 16:40:10 -0500
parents 15282c6612fb
children 9fe33afc00b4
line wrap: on
line diff
--- a/mercurial/commands.py	Tue Sep 30 15:55:30 2014 -0500
+++ b/mercurial/commands.py	Tue Sep 30 16:40:10 2014 -0500
@@ -3834,14 +3834,23 @@
         keep.append('unix')
         keep.append(sys.platform.lower())
 
+    section = None
+    if name and '.' in name:
+        name, section = name.split('.')
+
     text = help.help_(ui, name, **opts)
 
-    formatted, pruned = minirst.format(text, textwidth, keep=keep)
+    formatted, pruned = minirst.format(text, textwidth, keep=keep,
+                                       section=section)
+    if section and not formatted:
+        raise util.Abort(_("help section not found"))
+
     if 'verbose' in pruned:
         keep.append('omitted')
     else:
         keep.append('notomitted')
-    formatted, pruned = minirst.format(text, textwidth, keep=keep)
+    formatted, pruned = minirst.format(text, textwidth, keep=keep,
+                                       section=section)
     ui.write(formatted)