# HG changeset patch # User Matt Mackall # Date 2011-12-01 21:51:36 # Node ID 195dbd1cef0c2f9f8bcf4ea303238105f716bda3 # Parent c6be93a4c37890ff2763584e1302afb61ea26dbf alias: shortcut command matching show shadowing works properly (issue3104) An alias for 'log' was stored in the same command table as '^log|history'. If the hash function happens to give the latter first, the alias is effectively ignored when matching 'log'. diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -23,7 +23,14 @@ def findpossible(cmd, table, strict=Fals """ choice = {} debugchoice = {} - for e in table.keys(): + + if cmd in table: + # short-circuit exact matches, "log" alias beats "^log|history" + keys = [cmd] + else: + keys = table.keys() + + for e in keys: aliases = parsealiases(e) found = None if cmd in aliases: diff --git a/tests/test-alias.t b/tests/test-alias.t --- a/tests/test-alias.t +++ b/tests/test-alias.t @@ -395,3 +395,11 @@ invalid global arguments for normal comm use "hg help" for the full list of commands or "hg -v" for details [255] +This should show id: + + $ hg --config alias.log='id' log + 000000000000 tip + +This shouldn't: + + $ hg --config alias.log='id' history