# HG changeset patch # User timeless@mozdev.org # Date 2015-09-03 21:06:27 # Node ID 61124bf8485f82b325becc236d726f906baea24a # Parent ea888285311f5dfba0de2d5d4d53323ede328931 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`` ------------ diff --git a/mercurial/minirst.py b/mercurial/minirst.py --- a/mercurial/minirst.py +++ b/mercurial/minirst.py @@ -741,7 +741,10 @@ def getsections(blocks): 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 diff --git a/tests/test-help.t b/tests/test-help.t --- a/tests/test-help.t +++ b/tests/test-help.t @@ -922,6 +922,11 @@ Test repeated config section name "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