# HG changeset patch # User Brodie Rao # Date 1282445294 14400 # Node ID 18e1e7520b67bd233c16e952749c8e2f13006f19 # Parent 9617803b1acbb83e9611f56fe5666408110c2e1c 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. diff -r 9617803b1acb -r 18e1e7520b67 mercurial/dispatch.py --- 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