changeset 26170:61124bf8485f

minirst: handle edge in hunting for parents test for "hg help -c config" in help config ``section`` ----------- section text ``def1`` definition of def1 $ hg help scope.def1 should list this paragraph, but not section text below... section text ``def2`` definition of def2 $ hg help scope.def2 should list this paragraph, but not section text below... section text $ hg help scope.section should show everything from the first section text to this last line. ``section2`` ------------
author timeless@mozdev.org
date Thu, 03 Sep 2015 17:06:27 -0400
parents ea888285311f
children 49c1424424de
files mercurial/minirst.py tests/test-help.t
diffstat 2 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/minirst.py	Fri Sep 04 05:42:21 2015 -0400
+++ b/mercurial/minirst.py	Thu Sep 03 17:06:27 2015 -0400
@@ -741,7 +741,10 @@
                             break
                     pointer += 1
                 if pointer > 1:
-                    secs.append(('', secs[-pointer][1] + 1, []))
+                    blevel = secs[-pointer][1]
+                    if section['type'] != b['type']:
+                        blevel += 1
+                    secs.append(('', blevel, []))
             secs[-1][2].append(b)
     return secs
 
--- a/tests/test-help.t	Fri Sep 04 05:42:21 2015 -0400
+++ b/tests/test-help.t	Thu Sep 03 17:06:27 2015 -0400
@@ -922,6 +922,11 @@
       "smtp.host"
           Host name of mail server, e.g. "mail.example.com".
   
+Unrelated trailing paragraphs shouldn't be included
+
+  $ hg help config.extramsg | grep '^$'
+  
+
 Test capitalized section name
 
   $ hg help scripting.HGPLAIN > /dev/null