Mercurial > hg
changeset 12039:18e1e7520b67 stable
alias: make shadowing behavior more consistent (issue2054)
Currently, given an alias like the following:
[alias]
summary = summary --remote
The alias might be executed - or it might not - depending on the order
of the cmdtable dict.
This happens because cmdalias gets assigned back to the cmdtable like so:
cmdtable['summary'] = ...
Yet '^summary|sum' is still in the table, so which one cmdutil.findcmd()
chooses isn't deterministic.
This patch makes cmdalias assign back to '^summary|sum'. It uses the same
cmdtable key lookup that extensions.wrapcommand() does.
author | Brodie Rao <brodie@bitheap.org> |
---|---|
date | Sat, 21 Aug 2010 22:48:14 -0400 |
parents | 9617803b1acb |
children | 529e712cb1ba 8e7960feb139 |
files | mercurial/dispatch.py |
diffstat | 1 files changed, 7 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/dispatch.py Tue Aug 24 23:30:51 2010 +0900 +++ b/mercurial/dispatch.py Sat Aug 21 22:48:14 2010 -0400 @@ -182,7 +182,7 @@ class cmdalias(object): def __init__(self, name, definition, cmdtable): - self.name = name + self.name = self.cmd = name self.definition = definition self.args = [] self.opts = [] @@ -191,7 +191,11 @@ self.badalias = False try: - cmdutil.findcmd(self.name, cmdtable, True) + aliases, entry = cmdutil.findcmd(self.name, cmdtable) + for alias, e in cmdtable.iteritems(): + if e is entry: + self.cmd = alias + break self.shadows = True except error.UnknownCommand: self.shadows = False @@ -256,7 +260,7 @@ # but only if they have been defined prior to the current definition. for alias, definition in ui.configitems('alias'): aliasdef = cmdalias(alias, definition, cmdtable) - cmdtable[alias] = (aliasdef, aliasdef.opts, aliasdef.help) + cmdtable[aliasdef.cmd] = (aliasdef, aliasdef.opts, aliasdef.help) if aliasdef.norepo: commands.norepo += ' %s' % alias