comparison mercurial/extensions.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 af4387d8d1c7
children 6f72e7d28b35
comparison
equal deleted inserted replaced
19764:e92650e39f1c 19769:83d79a00cc24
347 if ext and 'DEPRECATED' not in ext.__doc__: 347 if ext and 'DEPRECATED' not in ext.__doc__:
348 return ext 348 return ext
349 349
350 raise error.UnknownCommand(cmd) 350 raise error.UnknownCommand(cmd)
351 351
352 def enabled(): 352 def enabled(shortname=True):
353 '''return a dict of {name: desc} of extensions''' 353 '''return a dict of {name: desc} of extensions'''
354 exts = {} 354 exts = {}
355 for ename, ext in extensions(): 355 for ename, ext in extensions():
356 doc = (gettext(ext.__doc__) or _('(no help text available)')) 356 doc = (gettext(ext.__doc__) or _('(no help text available)'))
357 ename = ename.split('.')[-1] 357 if shortname:
358 ename = ename.split('.')[-1]
358 exts[ename] = doc.splitlines()[0].strip() 359 exts[ename] = doc.splitlines()[0].strip()
359 360
360 return exts 361 return exts