Mercurial > hg
comparison mercurial/dispatch.py @ 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 | 0fa781320203 |
children | bd50aa1aa035 |
comparison
equal
deleted
inserted
replaced
34304:ae510d9691ef | 34305:0e48813cc106 |
---|---|
526 def addaliases(ui, cmdtable): | 526 def addaliases(ui, cmdtable): |
527 # aliases are processed after extensions have been loaded, so they | 527 # aliases are processed after extensions have been loaded, so they |
528 # may use extension commands. Aliases can also use other alias definitions, | 528 # may use extension commands. Aliases can also use other alias definitions, |
529 # but only if they have been defined prior to the current definition. | 529 # but only if they have been defined prior to the current definition. |
530 for alias, definition in ui.configitems('alias'): | 530 for alias, definition in ui.configitems('alias'): |
531 source = ui.configsource('alias', alias) | 531 try: |
532 aliasdef = cmdalias(alias, definition, cmdtable, source) | 532 if cmdtable[alias][0].definition == definition: |
533 | |
534 try: | |
535 olddef = cmdtable[aliasdef.cmd][0] | |
536 if olddef.definition == aliasdef.definition: | |
537 continue | 533 continue |
538 except (KeyError, AttributeError): | 534 except (KeyError, AttributeError): |
539 # definition might not exist or it might not be a cmdalias | 535 # definition might not exist or it might not be a cmdalias |
540 pass | 536 pass |
541 | 537 |
538 source = ui.configsource('alias', alias) | |
539 aliasdef = cmdalias(alias, definition, cmdtable, source) | |
542 cmdtable[aliasdef.name] = (aliasdef, aliasdef.opts, aliasdef.help) | 540 cmdtable[aliasdef.name] = (aliasdef, aliasdef.opts, aliasdef.help) |
543 | 541 |
544 def _parse(ui, args): | 542 def _parse(ui, args): |
545 options = {} | 543 options = {} |
546 cmdoptions = {} | 544 cmdoptions = {} |