Mercurial > hg-stable
changeset 28828:3640c1702c43
help: report source of aliases
author | timeless <timeless@mozdev.org> |
---|---|
date | Fri, 08 Apr 2016 18:35:49 +0000 |
parents | 1e184241de51 |
children | 65fb87479792 |
files | mercurial/dispatch.py mercurial/help.py tests/test-help.t |
diffstat | 3 files changed, 63 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/dispatch.py Fri Apr 08 16:05:52 2016 +0000 +++ b/mercurial/dispatch.py Fri Apr 08 18:35:49 2016 +0000 @@ -379,7 +379,7 @@ return r.sub(lambda x: replacemap[x.group()], cmd) class cmdalias(object): - def __init__(self, name, definition, cmdtable): + def __init__(self, name, definition, cmdtable, source): self.name = self.cmd = name self.cmdname = '' self.definition = definition @@ -389,6 +389,7 @@ self.help = '' self.badalias = None self.unknowncmd = False + self.source = source try: aliases, entry = cmdutil.findcmd(self.name, cmdtable) @@ -499,7 +500,8 @@ # may use extension commands. Aliases can also use other alias definitions, # but only if they have been defined prior to the current definition. for alias, definition in ui.configitems('alias'): - aliasdef = cmdalias(alias, definition, cmdtable) + source = ui.configsource('alias', alias) + aliasdef = cmdalias(alias, definition, cmdtable, source) try: olddef = cmdtable[aliasdef.cmd][0]
--- a/mercurial/help.py Fri Apr 08 16:05:52 2016 +0000 +++ b/mercurial/help.py Fri Apr 08 18:35:49 2016 +0000 @@ -336,10 +336,13 @@ if not doc: doc = _("(no help text available)") if util.safehasattr(entry[0], 'definition'): # aliased command + source = entry[0].source if entry[0].definition.startswith('!'): # shell alias - doc = _('shell alias for::\n\n %s') % entry[0].definition[1:] + doc = (_('shell alias for::\n\n %s\n\ndefined by: %s\n') % + (entry[0].definition[1:], source)) else: - doc = _('alias for: hg %s\n\n%s') % (entry[0].definition, doc) + doc = (_('alias for: hg %s\n\n%s\n\ndefined by: %s\n') % + (entry[0].definition, doc, source)) doc = doc.splitlines(True) if ui.quiet or not full: rst.append(doc[0])
--- a/tests/test-help.t Fri Apr 08 16:05:52 2016 +0000 +++ b/tests/test-help.t Fri Apr 08 18:35:49 2016 +0000 @@ -673,10 +673,50 @@ > def nohelp(ui, *args, **kwargs): > pass > + > def uisetup(ui): + > ui.setconfig('alias', 'shellalias', '!echo hi', 'helpext') + > ui.setconfig('alias', 'hgalias', 'summary', 'helpext') + > > EOF $ echo '[extensions]' >> $HGRCPATH $ echo "helpext = `pwd`/helpext.py" >> $HGRCPATH +Test for aliases + + $ hg help hgalias + hg hgalias [--remote] + + alias for: hg summary + + summarize working directory state + + This generates a brief summary of the working directory state, including + parents, branch, commit status, phase and available updates. + + With the --remote option, this will check the default paths for incoming + and outgoing changes. This can be time-consuming. + + Returns 0 on success. + + defined by: helpext + + options: + + --remote check for push and pull + + (some details hidden, use --verbose to show complete help) + + $ hg help shellalias + hg shellalias + + shell alias for: + + echo hi + + defined by: helpext + + (some details hidden, use --verbose to show complete help) + Test command with no help text $ hg help nohelp @@ -2064,6 +2104,13 @@ show help for a given topic or a help overview </td></tr> <tr><td> + <a href="/help/hgalias"> + hgalias + </a> + </td><td> + summarize working directory state + </td></tr> + <tr><td> <a href="/help/identify"> identify </a> @@ -2155,6 +2202,13 @@ print the root (top) of the current working directory </td></tr> <tr><td> + <a href="/help/shellalias"> + shellalias + </a> + </td><td> + (no help text available) + </td></tr> + <tr><td> <a href="/help/tag"> tag </a>