[PATCH 2 of 2] extensions: pass ui arguement to extsetup if accepted

Simon Heimberg simohe at besonet.ch
Wed Aug 26 16:02:22 CDT 2009


# HG changeset patch
# User Simon Heimberg <simohe at besonet.ch>
# Date 1250376084 -7200
# Node ID 5f4e2711e3b2f1de44ce92616be43c5aa38e3e77
# Parent  51ca46023b3844b11ee304555ac6f23b7581d67c
extensions: pass ui arguement to extsetup if accepted

diff -r 51ca46023b38 -r 5f4e2711e3b2 mercurial/extensions.py
--- a/mercurial/extensions.py	Son Aug 16 00:41:14 2009 +0200
+++ b/mercurial/extensions.py	Son Aug 16 00:41:24 2009 +0200
@@ -117,7 +117,12 @@
     for name, mod in unloaded:
         extsetup = getattr(mod, 'extsetup', None)
         if extsetup:
-            extsetup()
+            try:
+                extsetup(ui)
+            except TypeError:
+                if extsetup.func_code.co_argcount != 0:
+                    raise
+                extsetup() # old extsetup with no ui argument
     for name, mod in unloaded:
         cmdtable = getattr(mod, 'cmdtable', {})
         overrides = [cmd for cmd in cmdtable if cmd in commands.table]


More information about the Mercurial-devel mailing list