summaryrefslogtreecommitdiff
path: root/morphlib/sourcepool.py
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@gmail.com>2014-09-03 21:03:56 +0000
committerRichard Maw <richard.maw@gmail.com>2014-09-19 12:43:26 +0000
commit30bd3185050bc7997a032ca32f0a5ac9b5e76ed9 (patch)
tree8f2c011823945af4d79e9e5bc850477a61b58e5f /morphlib/sourcepool.py
parente3400ec5a25b5163293adcb0d007d0a8cae53a4c (diff)
downloadmorph-30bd3185050bc7997a032ca32f0a5ac9b5e76ed9.tar.gz
Create multiple sources per stratum morphology
Building per-artifact results in undesirable behaviour, as multiple artifacts are produced for every chunk build. It therefore makes more sense to build per-source. This implies that actually, the model of one source per morphology is wrong and we should move the dependencies into the source. Unlike chunks however, where every chunk artifact has the same dependencies, stratum artifacts can have different dependencies. So before we can move the dependencies into the Source, we need to have as many Sources as Stratum Artifacts.
Diffstat (limited to 'morphlib/sourcepool.py')
-rw-r--r--morphlib/sourcepool.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/morphlib/sourcepool.py b/morphlib/sourcepool.py
index ec134c0a..6dfcb2c3 100644
--- a/morphlib/sourcepool.py
+++ b/morphlib/sourcepool.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012 Codethink Limited
+# Copyright (C) 2012-2014 Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -14,12 +14,15 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+import collections
+
+
class SourcePool(object):
'''Manage a collection of Source objects.'''
def __init__(self):
- self._sources = {}
+ self._sources = collections.defaultdict(dict)
self._order = []
def _key(self, repo_name, original_ref, filename):
@@ -30,8 +33,8 @@ class SourcePool(object):
key = self._key(source.repo_name,
source.original_ref,
source.filename)
- if key not in self._sources:
- self._sources[key] = source
+ if key not in self._sources or source.name not in self._sources[key]:
+ self._sources[key][source.name] = source
self._order.append(source)
def lookup(self, repo_name, original_ref, filename):
@@ -42,7 +45,7 @@ class SourcePool(object):
'''
key = self._key(repo_name, original_ref, filename)
- return self._sources[key]
+ return self._sources[key].values()
def __iter__(self):
'''Iterate over sources in the pool, in the order they were added.'''