changeset 15019:f4b7be3f8430 stable

dispatch: don't rewrap aliases that have the same definition Previously aliases that overrode existing commands would wrap the old alias on every call to dispatch() (twice actually), which is an obvious re-entrancy issue for things like the command server or TortoiseHG.
author Idan Kamara <idankk86@gmail.com>
date Thu, 04 Aug 2011 19:41:23 +0300
parents e89f62dcd723
children 0f1311e829c9
files mercurial/dispatch.py
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dispatch.py	Thu Aug 04 02:51:29 2011 +0200
+++ b/mercurial/dispatch.py	Thu Aug 04 19:41:23 2011 +0300
@@ -354,6 +354,15 @@
     # but only if they have been defined prior to the current definition.
     for alias, definition in ui.configitems('alias'):
         aliasdef = cmdalias(alias, definition, cmdtable)
+
+        try:
+            olddef = cmdtable[aliasdef.cmd][0]
+            if olddef.definition == aliasdef.definition:
+                continue
+        except (KeyError, AttributeError):
+            # definition might not exist or it might not be a cmdalias
+            pass
+
         cmdtable[aliasdef.cmd] = (aliasdef, aliasdef.opts, aliasdef.help)
         if aliasdef.norepo:
             commands.norepo += ' %s' % alias