Make component creation happen on-demand for both manual and automatic
authorKalle Vahlman <kalle.vahlman@movial.com>
Wed, 13 May 2009 10:59:44 +0000 (13:59 +0300)
committerKalle Vahlman <kalle.vahlman@movial.com>
Wed, 13 May 2009 11:13:28 +0000 (14:13 +0300)
components. The introduction of remote hash-tracking made checking
all manual components unconditionally painful.

matrix/components.py

index 98587be..93b6387 100644 (file)
@@ -91,11 +91,23 @@ class Resolver(object):
                self.packages = {}
 
        def resolve(self, targets):
-               # add all manually specified components before dependencies so
-               # that all custom Component() arguments will come into effect
+               # add target components before dependencies so that all custom
+               # Component() arguments will come into effect
                #
-               for c in config.components.itervalues():
-                       self.add_component(c)
+               for name in targets:
+                       # target might be an automatic component, those
+                       # will be added after the dep resolving stage
+                       #
+                       try:
+                               self.add_component(config.components[name])
+                       except KeyError:
+                               pass
+
+               # if there's no targets, add all manually defined components
+               if not targets:
+                       for c in config.components.itervalues():
+                               self.add_component(c)
+
 
                # iterate over a _copy_ of the _current_ package list;
                # automatic components' dependencies will be initialized
@@ -167,7 +179,12 @@ class Resolver(object):
                if config.debug:
                        print 'Looking for automatic component:', name
 
-               c = Component(name)
+               # There might be config options for the component
+               try:
+                       c = config.components[name]
+               except KeyError:
+                       c = Component(name)
+
                if not c.meta.exists():
                        try:
                                c.meta.clone()