[PATCH 5 of 7] help: reorder section filtering flow to not format help text twice
Yuya Nishihara
yuya at tcha.org
Wed Aug 22 08:19:53 EDT 2018
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1533439243 -32400
# Sun Aug 05 12:20:43 2018 +0900
# Node ID 7ba0774e0bbdb9ed5b87a9e27bef443adab09c85
# Parent f2a08652109f187a75d00dd2af76ba51fb7494e1
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)
More information about the Mercurial-devel
mailing list