Make contract with extensions optional.
authorBryan O'Sullivan <bos@serpentine.com>
Wed, 21 Sep 2005 14:22:16 -0700
changeset 1295 abcdf14449ea
parent 1294 372971e1c40d
child 1296 7b4249a4a383
Make contract with extensions optional.
mercurial/commands.py
--- a/mercurial/commands.py	Wed Sep 21 13:33:24 2005 -0700
+++ b/mercurial/commands.py	Wed Sep 21 14:22:16 2005 -0700
@@ -2053,10 +2053,11 @@
             mod = importh(x[0])
         external.append(mod)
     for x in external:
-        for t in x.cmdtable:
+        cmdtable = getattr(x, 'cmdtable', {})
+        for t in cmdtable:
             if t in table:
-                u.warn("module %s override %s\n" % (x.__name__, t))
-        table.update(x.cmdtable)
+                u.warn("module %s overrides %s\n" % (x.__name__, t))
+        table.update(cmdtable)
 
     try:
         cmd, func, args, options, cmdoptions = parse(args)
@@ -2116,7 +2117,7 @@
                 path = options["repository"] or ""
                 repo = hg.repository(ui=u, path=path)
                 for x in external:
-                    x.reposetup(u, repo)
+                    if hasattr(x, 'reposetup'): x.reposetup(u, repo)
                 d = lambda: func(u, repo, *args, **cmdoptions)
             else:
                 d = lambda: func(u, *args, **cmdoptions)