[PATCH STABLE] dispatch: don't rewrap aliases that have the same definition

Idan Kamara idankk86 at gmail.com
Thu Aug 4 11:50:19 CDT 2011


# HG changeset patch
# User Idan Kamara <idankk86 at gmail.com>
# Date 1312476083 -10800
# Branch stable
# Node ID cf682873ec99b0b2cf91a9c27c1af0903e5e804a
# Parent  9991f8b19ff3fe353690646b2b2bb77e4db4981e
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.

diff -r 9991f8b19ff3 -r cf682873ec99 mercurial/dispatch.py
--- a/mercurial/dispatch.py	Mon Aug 01 18:09:20 2011 -0500
+++ 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


More information about the Mercurial-devel mailing list