# HG changeset patch # User Jun Wu # Date 2017-09-23 20:31:09 # Node ID 0e48813cc106ca63600d77d2847a6721a7288ae3 # Parent ae510d9691efec90640d17fc61c56272c433fe95 alias: test duplicated definition earlier This patch moves the old definition checking logic introduced by f4b7be3f8430 earlier. So that the test itself does not depend on `aliasdef`. The check is to avoid wrapping a same alias multiple times. It can be done by checking the config name and value (`definition` in code), without constructing a `cmdalias` instance. This makes the next patch easier to review. Differential Revision: https://phab.mercurial-scm.org/D804 diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py --- a/mercurial/dispatch.py +++ b/mercurial/dispatch.py @@ -528,17 +528,15 @@ def addaliases(ui, cmdtable): # 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'): - source = ui.configsource('alias', alias) - aliasdef = cmdalias(alias, definition, cmdtable, source) - try: - olddef = cmdtable[aliasdef.cmd][0] - if olddef.definition == aliasdef.definition: + if cmdtable[alias][0].definition == definition: continue except (KeyError, AttributeError): # definition might not exist or it might not be a cmdalias pass + source = ui.configsource('alias', alias) + aliasdef = cmdalias(alias, definition, cmdtable, source) cmdtable[aliasdef.name] = (aliasdef, aliasdef.opts, aliasdef.help) def _parse(ui, args):