Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/help.py @ 19769:83d79a00cc24 stable
help: use full name of extensions to look up them for keyword search
Before this patch, "hg help -k KEYWORD" fails, if there is the
extension of which name includes ".", because "extensions.load()"
invoked from "help.topicmatch()" fails to look such extension up, even
though it is already loaded in.
"help.topicmatch()" invokes "extensions.load()" with the name gotten
from "extensions.enabled()". The former expects full name of extension
(= key in '[extensions]' section), but the latter returns names
shortened by "split('.')[-1]". This difference causes failure of
looking extension up.
This patch adds "shortname" argument to "extensions.enabled()" to make
it return shortened names only if it is True. "help.topicmatch()"
turns it off to get full name of extensions.
Then, this patch shortens full name of extensions by "split('.')[-1]"
for showing them in the list of extensions.
Shortening is also applied on names gotten from
"extensions.disabled()" but harmless, because it returns only
extensions directly under "hgext" and their names should not include
".".
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Mon, 23 Sep 2013 20:23:25 +0900 |
parents | 6e676fb6ea44 |
children | 1e5b38a919dd |
comparison
equal
deleted
inserted
replaced
19764:e92650e39f1c | 19769:83d79a00cc24 |
---|---|
101 if doclines: | 101 if doclines: |
102 summary = doclines[0] | 102 summary = doclines[0] |
103 cmdname = cmd.split('|')[0].lstrip('^') | 103 cmdname = cmd.split('|')[0].lstrip('^') |
104 results['commands'].append((cmdname, summary)) | 104 results['commands'].append((cmdname, summary)) |
105 for name, docs in itertools.chain( | 105 for name, docs in itertools.chain( |
106 extensions.enabled().iteritems(), | 106 extensions.enabled(False).iteritems(), |
107 extensions.disabled().iteritems()): | 107 extensions.disabled().iteritems()): |
108 # extensions.load ignores the UI argument | 108 # extensions.load ignores the UI argument |
109 mod = extensions.load(None, name, '') | 109 mod = extensions.load(None, name, '') |
110 name = name.split('.')[-1] | |
110 if lowercontains(name) or lowercontains(docs): | 111 if lowercontains(name) or lowercontains(docs): |
111 # extension docs are already translated | 112 # extension docs are already translated |
112 results['extensions'].append((name, docs.splitlines()[0])) | 113 results['extensions'].append((name, docs.splitlines()[0])) |
113 for cmd, entry in getattr(mod, 'cmdtable', {}).iteritems(): | 114 for cmd, entry in getattr(mod, 'cmdtable', {}).iteritems(): |
114 if kw in cmd or (len(entry) > 2 and lowercontains(entry[2])): | 115 if kw in cmd or (len(entry) > 2 and lowercontains(entry[2])): |