Patchwork [1,of,3] help: refactor filtercmd

login
register
mail settings
Submitter timeless@mozdev.org
Date Dec. 9, 2015, 7:24 p.m.
Message ID <4fbed691a2eb16e18069.1449689043@waste.org>
Download mbox | patch
Permalink /patch/11952/
State Accepted
Headers show

Comments

timeless@mozdev.org - Dec. 9, 2015, 7:24 p.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1449688146 0
#      Wed Dec 09 19:09:06 2015 +0000
# Node ID 4fbed691a2eb16e180692a192760cd3669f0ecd3
# Parent  42aa0e570eaa364a622bc4443b0bcb79b1100a58
help: refactor filtercmd

Patch

diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -84,6 +84,13 @@ 
     if notomitted:
         rst.append('\n\n.. container:: notomitted\n\n    %s\n\n' % notomitted)
 
+def filtercmd(ui, cmd, kw, doc):
+    if not ui.debugflag and cmd.startswith("debug") and kw != "debug":
+        return True
+    if not ui.verbose and doc and any(w in doc for w in _exclkeywords):
+        return True
+    return False
+
 def topicmatch(ui, kw):
     """Return help topics matching kw.
 
@@ -340,10 +347,8 @@ 
             if name == "shortlist" and not f.startswith("^"):
                 continue
             f = f.lstrip("^")
-            if not ui.debugflag and f.startswith("debug") and name != "debug":
-                continue
             doc = e[0].__doc__
-            if not ui.verbose and doc and any(w in doc for w in _exclkeywords):
+            if filtercmd(ui, f, name, doc):
                 continue
             doc = gettext(doc)
             if not doc: