summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2014-11-25 20:29:44 +0000
committerAdam Coldrick <adam.coldrick@codethink.co.uk>2015-02-18 10:31:43 +0000
commit0f5f4821d801bb906d81259a58cf79e7c9aeb312 (patch)
treef1bd151a93f4f7e6549a40c0c8fec45309791354
parent5b026a15f2fb503d5402c056e4d0f1187c6f5417 (diff)
downloadmorph-0f5f4821d801bb906d81259a58cf79e7c9aeb312.tar.gz
sourceresolver: Add comments and factor out common function
-rw-r--r--morphlib/sourceresolver.py28
1 files changed, 15 insertions, 13 deletions
diff --git a/morphlib/sourceresolver.py b/morphlib/sourceresolver.py
index 3a328eb7..4bc55bf2 100644
--- a/morphlib/sourceresolver.py
+++ b/morphlib/sourceresolver.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2014 Codethink Limited
+# Copyright (C) 2014-2015 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
@@ -117,6 +117,10 @@ class SourceResolver(object):
if definitions_original_ref:
definitions_ref = definitions_original_ref
+ # First, process the system and its stratum morphologies. These will
+ # all live in the same Git repository, and will point to various chunk
+ # morphologies.
+
while definitions_queue:
filename = definitions_queue.popleft()
@@ -127,6 +131,7 @@ class SourceResolver(object):
visit(definitions_repo, definitions_ref, filename,
definitions_absref, definitions_tree, morphology)
+
if morphology['kind'] == 'cluster':
raise cliapp.AppException(
"Cannot build a morphology of type 'cluster'.")
@@ -149,7 +154,11 @@ class SourceResolver(object):
chunk_in_definitions_repo_queue.append(
(c['repo'], c['ref'], c['morph']))
- for repo, ref, filename in chunk_in_definitions_repo_queue:
+ # Now process all the chunks involved in the build. First those with
+ # morphologies in definitions.git, and then (for compatibility reasons
+ # only) those with the morphology in the chunk's source repository.
+
+ def process_chunk(repo, ref, filename):
if (repo, ref) not in resolved_trees:
commit_sha1, tree_sha1 = self.resolve_ref(repo, ref)
resolved_commits[repo, ref] = commit_sha1
@@ -162,18 +171,11 @@ class SourceResolver(object):
morphology = resolved_morphologies[key]
visit(repo, ref, filename, absref, tree, morphology)
+ for repo, ref, filename in chunk_in_definitions_repo_queue:
+ process_chunk_repo(repo, ref, filename)
+
for repo, ref, filename in chunk_in_source_repo_queue:
- if (repo, ref) not in resolved_trees:
- commit_sha1, tree_sha1 = self.resolve_ref(repo, ref)
- resolved_commits[repo, ref] = commit_sha1
- resolved_trees[repo, commit_sha1] = tree_sha1
- absref = resolved_commits[repo, ref]
- tree = resolved_trees[repo, absref]
- key = (repo, absref, filename)
- if key not in resolved_morphologies:
- resolved_morphologies[key] = morph_factory.get_morphology(*key)
- morphology = resolved_morphologies[key]
- visit(repo, ref, filename, absref, tree, morphology)
+ process_chunk_repo(repo, ref, filename)
def create_source_pool(lrc, rrc, repo, ref, filename,