Mercurial > hg
changeset 34305:0e48813cc106
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
author | Jun Wu <quark@fb.com> |
---|---|
date | Sat, 23 Sep 2017 13:31:09 -0700 |
parents | ae510d9691ef |
children | bd50aa1aa035 |
files | mercurial/dispatch.py |
diffstat | 1 files changed, 3 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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):