D804: alias: test duplicated definition earlier
quark (Jun Wu)
phabricator at mercurial-scm.org
Sat Sep 23 20:57:52 UTC 2017
quark created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
This patch moves the old definition checking logic introduced by
https://phab.mercurial-scm.org/rHGf4b7be3f843098c50d7da88a2231e2a9efe29730 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.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D804
AFFECTED FILES
mercurial/dispatch.py
CHANGE DETAILS
diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -528,17 +528,16 @@
# 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:
+ olddef = cmdtable[alias][0]
+ if olddef.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):
To: quark, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list