# HG changeset patch # User Yuya Nishihara # Date 2018-08-05 03:20:43 # Node ID 0a766cb1092a2d798e44c008cb3989f653a01c0b # Parent 9b800601701ca156dd90789b8d0e6a540e5e1a57 help: reorder section filtering flow to not format help text twice diff --git a/mercurial/help.py b/mercurial/help.py --- a/mercurial/help.py +++ b/mercurial/help.py @@ -673,16 +673,6 @@ def formattedhelp(ui, commands, name, ke 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 @@ def formattedhelp(ui, commands, name, ke 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)