changeset 1295:abcdf14449ea

Make contract with extensions optional.
author Bryan O'Sullivan <bos@serpentine.com>
date Wed, 21 Sep 2005 14:22:16 -0700
parents 372971e1c40d
children 7b4249a4a383
files mercurial/commands.py
diffstat 1 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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)