# HG changeset patch # User Jun Wu # Date 1506198669 25200 # 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 -r ae510d9691ef -r 0e48813cc106 mercurial/dispatch.py --- a/mercurial/dispatch.py Sun Sep 24 19:37:55 2017 +0530 +++ b/mercurial/dispatch.py Sat Sep 23 13:31:09 2017 -0700 @@ -528,17 +528,15 @@ # 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):