changeset 22770:de9424647fe4

help: show all nested subsections of a section with `hg help foo.section` Used to be that `hg help hgrc.paths` would show "paths" ------- Assigns symbolic names to repositories. The left side is the symbolic name, and the right gives the directory or URL that is the location of the repository. Default paths can be declared by setting the following entries. and stop there. Obviously the result seems better as shown in the attached test.
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Mon, 06 Oct 2014 07:35:53 -0400
parents 3f808549d426
children d6274291fac1
files mercurial/minirst.py tests/test-help.t
diffstat 2 files changed, 40 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/minirst.py	Mon Oct 06 07:29:38 2014 -0400
+++ b/mercurial/minirst.py	Mon Oct 06 07:35:53 2014 -0400
@@ -654,9 +654,18 @@
     if section:
         sections = getsections(blocks)
         blocks = []
-        for name, nest, b in sections:
+        i = 0
+        while i < len(sections):
+            name, nest, b = sections[i]
             if name == section:
-                blocks = b
+                blocks.extend(b)
+
+                ## Also show all subnested sections
+                while i + 1 < len(sections) and sections[i + 1][1] > nest:
+                    i += 1
+                    blocks.extend(sections[i][2])
+            i += 1
+
     if style == 'html':
         text = formathtml(blocks)
     else:
--- a/tests/test-help.t	Mon Oct 06 07:29:38 2014 -0400
+++ b/tests/test-help.t	Mon Oct 06 07:35:53 2014 -0400
@@ -1061,6 +1061,35 @@
           graphical tools such as "hg log --graph". In Mercurial, the DAG is
           limited by the requirement for children to have at most two parents.
   
+
+  $ hg help hgrc.paths
+      "paths"
+      -------
+  
+      Assigns symbolic names to repositories. The left side is the symbolic
+      name, and the right gives the directory or URL that is the location of the
+      repository. Default paths can be declared by setting the following
+      entries.
+  
+      "default"
+          Directory or URL to use when pulling if no source is specified.
+          Default is set to repository from which the current repository was
+          cloned.
+  
+      "default-push"
+          Optional. Directory or URL to use when pushing if no destination is
+          specified.
+  
+      Custom paths can be defined by assigning the path to a name that later can
+      be used from the command line. Example:
+  
+        [paths]
+        my_path = http://example.com/path
+  
+      To push to the path defined in "my_path" run the command:
+  
+        hg push my_path
+  
   $ hg help glossary.mcguffin
   abort: help section not found
   [255]