Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/help.py @ 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 | 8225bb1f0ad3 |
children | c5df4af17110 |
comparison
equal
deleted
inserted
replaced
22317:e1d5fcab58b6 | 22322:e284de138f00 |
---|---|
84 'commands': [], | 84 'commands': [], |
85 'extensions': [], | 85 'extensions': [], |
86 'extensioncommands': [], | 86 'extensioncommands': [], |
87 } | 87 } |
88 for names, header, doc in helptable: | 88 for names, header, doc in helptable: |
89 # Old extensions may use a str as doc. | |
89 if (sum(map(lowercontains, names)) | 90 if (sum(map(lowercontains, names)) |
90 or lowercontains(header) | 91 or lowercontains(header) |
91 or lowercontains(doc())): | 92 or (callable(doc) and lowercontains(doc()))): |
92 results['topics'].append((names[0], header)) | 93 results['topics'].append((names[0], header)) |
93 import commands # avoid cycle | 94 import commands # avoid cycle |
94 for cmd, entry in commands.table.iteritems(): | 95 for cmd, entry in commands.table.iteritems(): |
95 if len(entry) == 3: | 96 if len(entry) == 3: |
96 summary = entry[2] | 97 summary = entry[2] |