Mercurial > hg
changeset 39309:0a766cb1092a
help: reorder section filtering flow to not format help text twice
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 05 Aug 2018 12:20:43 +0900 |
parents | 9b800601701c |
children | a2a5d4ad5276 |
files | mercurial/help.py |
diffstat | 1 files changed, 7 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/help.py Sun Aug 05 12:06:07 2018 +0900 +++ b/mercurial/help.py Sun Aug 05 12:20:43 2018 +0900 @@ -673,16 +673,6 @@ subtopic=subtopic, unknowncmd=unknowncmd, full=full, **opts) blocks, pruned = minirst.parse(text, keep=keep) - if section: - blocks = minirst.filtersections(blocks, section) - formatted = minirst.formatplain(blocks, textwidth) - - # We could have been given a weird ".foo" section without a name - # to look for, or we could have simply failed to found "foo.bar" - # because bar isn't a section of foo - if section and not (formatted and name): - raise error.Abort(_("help section not found: %s") % fullname) - if 'verbose' in pruned: keep.append('omitted') else: @@ -690,4 +680,11 @@ blocks, pruned = minirst.parse(text, keep=keep) if section: blocks = minirst.filtersections(blocks, section) + + # We could have been given a weird ".foo" section without a name + # to look for, or we could have simply failed to found "foo.bar" + # because bar isn't a section of foo + if section and not (blocks and name): + raise error.Abort(_("help section not found: %s") % fullname) + return minirst.formatplain(blocks, textwidth)