changeset 22322:e284de138f00 stable

help: only call doc() when it is callable `hg help -k` on my machine was aborting because the hg-prompt extension was inserting a string and not a function into help.helptable and help was blindly calling it. This patch changes keyword searching to be more robust against unexpected types.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 30 Aug 2014 20:06:24 +0200
parents e1d5fcab58b6
children 5dc91146f353
files mercurial/help.py
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/help.py	Sun Aug 31 19:43:03 2014 +0900
+++ b/mercurial/help.py	Sat Aug 30 20:06:24 2014 +0200
@@ -86,9 +86,10 @@
                'extensioncommands': [],
                }
     for names, header, doc in helptable:
+        # Old extensions may use a str as doc.
         if (sum(map(lowercontains, names))
             or lowercontains(header)
-            or lowercontains(doc())):
+            or (callable(doc) and lowercontains(doc()))):
             results['topics'].append((names[0], header))
     import commands # avoid cycle
     for cmd, entry in commands.table.iteritems():