diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2012-12-03 16:55:12 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2012-12-03 16:55:12 +0000 |
commit | 94d3eb227bc367bd03053057c7e63e001886600f (patch) | |
tree | a2c664a98822939713f12833766edf4e873a50ff | |
parent | 8cd95022df4a01a9ffa2f36a4118d0ace8ddbdc0 (diff) | |
parent | 2115e5caac731ad3a483cbb863e2b371f7a6e7d5 (diff) | |
download | morph-94d3eb227bc367bd03053057c7e63e001886600f.tar.gz |
Merge branch 'baserock/richardmaw/build-less-artifacts'
Rubber stamped because the usual reviewers are on holiday.
-rw-r--r-- | morphlib/cachekeycomputer_tests.py | 18 | ||||
-rw-r--r-- | morphlib/sourcepool.py | 5 |
2 files changed, 19 insertions, 4 deletions
diff --git a/morphlib/cachekeycomputer_tests.py b/morphlib/cachekeycomputer_tests.py index 7077a313..411ad3f5 100644 --- a/morphlib/cachekeycomputer_tests.py +++ b/morphlib/cachekeycomputer_tests.py @@ -173,8 +173,13 @@ class CacheKeyComputerTests(unittest.TestCase): new_source = morphlib.source.Source('repo', 'original/ref', 'newsha', 'tree', morphology, old_artifact.source.filename) - self.source_pool.add(new_source) - artifacts = self.artifact_resolver.resolve_artifacts(self.source_pool) + sp = morphlib.sourcepool.SourcePool() + for source in self.source_pool: + if source == old_artifact.source: + sp.add(new_source) + else: + sp.add(source) + artifacts = self.artifact_resolver.resolve_artifacts(sp) for new_artifact in artifacts: if new_artifact.source == new_source: break @@ -184,3 +189,12 @@ class CacheKeyComputerTests(unittest.TestCase): old_sha = self.ckc.compute_key(old_artifact) new_sha = self.ckc.compute_key(new_artifact) self.assertEqual(old_sha, new_sha) + + def test_same_morphology_added_to_source_pool_only_appears_once(self): + src = morphlib.source.Source('repo', 'original/ref', 'sha', 'tree', + '{"name": "chunk", "kind": "chunk"}', + 'chunk.morph') + sp = morphlib.sourcepool.SourcePool() + sp.add(src) + sp.add(src) + self.assertEqual(1, len([s for s in sp if s == src])) diff --git a/morphlib/sourcepool.py b/morphlib/sourcepool.py index ef21ba5a..ec134c0a 100644 --- a/morphlib/sourcepool.py +++ b/morphlib/sourcepool.py @@ -30,8 +30,9 @@ class SourcePool(object): key = self._key(source.repo_name, source.original_ref, source.filename) - self._sources[key] = source - self._order.append(source) + if key not in self._sources: + self._sources[key] = source + self._order.append(source) def lookup(self, repo_name, original_ref, filename): '''Find a source in the pool. |