Mercurial > hg-stable
changeset 36283:4174970c9147
help: use cmdutil.parsealiases() to resolve command name
This seems slightly better than parsing '^command|name' string by using an
ad-hoc pattern.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Mon, 08 Jan 2018 12:09:43 +0900 |
parents | c792f7c64f0c |
children | c2c5f9f6fa21 |
files | mercurial/help.py |
diffstat | 1 files changed, 11 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/help.py Sun Dec 27 14:13:27 2015 +0900 +++ b/mercurial/help.py Mon Jan 08 12:09:43 2018 +0900 @@ -150,7 +150,7 @@ doclines = docs.splitlines() if doclines: summary = doclines[0] - cmdname = cmd.partition('|')[0].lstrip('^') + cmdname = cmdutil.parsealiases(cmd)[0] if filtercmd(ui, cmdname, kw, docs): continue results['commands'].append((cmdname, summary)) @@ -170,7 +170,7 @@ continue for cmd, entry in getattr(mod, 'cmdtable', {}).iteritems(): if kw in cmd or (len(entry) > 2 and lowercontains(entry[2])): - cmdname = cmd.partition('|')[0].lstrip('^') + cmdname = cmdutil.parsealiases(cmd)[0] cmddoc = pycompat.getdoc(entry[0]) if cmddoc: cmddoc = gettext(cmddoc).splitlines()[0] @@ -328,7 +328,7 @@ # py3k fix: except vars can't be used outside the scope of the # except block, nor can be used inside a lambda. python issue4617 prefix = inst.args[0] - select = lambda c: c.lstrip('^').startswith(prefix) + select = lambda c: cmdutil.parsealiases(c)[0].startswith(prefix) rst = helplist(select) return rst @@ -419,15 +419,18 @@ h = {} cmds = {} for c, e in commands.table.iteritems(): - f = c.partition("|")[0] - if select and not select(f): + fs = cmdutil.parsealiases(c) + f = fs[0] + p = '' + if c.startswith("^"): + p = '^' + if select and not select(p + f): continue if (not select and name != 'shortlist' and e[0].__module__ != commands.__name__): continue - if name == "shortlist" and not f.startswith("^"): + if name == "shortlist" and not p: continue - f = f.lstrip("^") doc = pycompat.getdoc(e[0]) if filtercmd(ui, f, name, doc): continue @@ -435,7 +438,7 @@ if not doc: doc = _("(no help text available)") h[f] = doc.splitlines()[0].rstrip() - cmds[f] = c.lstrip("^") + cmds[f] = '|'.join(fs) rst = [] if not h: