# HG changeset patch # User FUJIWARA Katsunori # Date 2013-09-23 11:23:25 # Node ID 83d79a00cc244651b8cf8541bb273f6cf798f807 # Parent e92650e39f1cd8ff7565c583e8bf0fa0bdac364d 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 ".". diff --git a/mercurial/extensions.py b/mercurial/extensions.py --- a/mercurial/extensions.py +++ b/mercurial/extensions.py @@ -349,12 +349,13 @@ def disabledcmd(ui, cmd, strict=False): raise error.UnknownCommand(cmd) -def enabled(): +def enabled(shortname=True): '''return a dict of {name: desc} of extensions''' exts = {} for ename, ext in extensions(): doc = (gettext(ext.__doc__) or _('(no help text available)')) - ename = ename.split('.')[-1] + if shortname: + ename = ename.split('.')[-1] exts[ename] = doc.splitlines()[0].strip() return exts diff --git a/mercurial/help.py b/mercurial/help.py --- a/mercurial/help.py +++ b/mercurial/help.py @@ -103,10 +103,11 @@ def topicmatch(kw): cmdname = cmd.split('|')[0].lstrip('^') results['commands'].append((cmdname, summary)) for name, docs in itertools.chain( - extensions.enabled().iteritems(), + extensions.enabled(False).iteritems(), extensions.disabled().iteritems()): # extensions.load ignores the UI argument mod = extensions.load(None, name, '') + name = name.split('.')[-1] if lowercontains(name) or lowercontains(docs): # extension docs are already translated results['extensions'].append((name, docs.splitlines()[0])) diff --git a/tests/test-help.t b/tests/test-help.t --- a/tests/test-help.t +++ b/tests/test-help.t @@ -773,6 +773,12 @@ Test help hooks Test keyword search help + $ cat > prefixedname.py < '''matched against word "clone" + > ''' + > EOF + $ echo '[extensions]' >> $HGRCPATH + $ echo "dot.dot.prefixedname = `pwd`/prefixedname.py" >> $HGRCPATH $ hg help -k clone Topics: @@ -792,7 +798,8 @@ Test keyword search help Extensions: - relink recreates hardlinks between repository clones + prefixedname matched against word "clone" + relink recreates hardlinks between repository clones Extension Commands: