summaryrefslogtreecommitdiff
path: root/morph
diff options
context:
space:
mode:
authorJannis Pohlmann <jannis.pohlmann@codethink.co.uk>2012-01-31 16:38:18 +0000
committerJannis Pohlmann <jannis.pohlmann@codethink.co.uk>2012-01-31 16:42:41 +0000
commitc2104eb199916f9ef7e7b77d0eebf33619ed3ea9 (patch)
tree01eb904eda1461bf70ecf97aa8f6445d0bbfbb07 /morph
parentab965be42d10f2608dc883ee0cc34a1cd0fe5058 (diff)
downloadmorph-c2104eb199916f9ef7e7b77d0eebf33619ed3ea9.tar.gz
Properly unpack dependencies into the staging area in build-single.
This requires build-single to take a dependency context tuple when building chunks of a stratum. This context tuple is the surrounding stratum which is used to construct the dependency graph in the worker and then do a breadth-first search to collect all dependencies that need to be added to the staging area. Implementing this required a few hash/eq changes in Blob, Morphology and Treeish as well as a few adjustments in the corresponding unit tests.
Diffstat (limited to 'morph')
-rwxr-xr-xmorph45
1 files changed, 39 insertions, 6 deletions
diff --git a/morph b/morph
index ce2838ac..db86bb69 100755
--- a/morph
+++ b/morph
@@ -228,20 +228,53 @@ class Morph(cliapp.Application):
os.mkdir(self.settings['cachedir'])
ret = []
- while len(args) >= 3:
+ if len(args) >= 3:
repo, ref, filename = args[:3]
args = args[3:]
# derive a build order from the dependency graph
graph = BuildDependencyGraph(source_manager, morph_loader,
repo, ref, filename)
- blob = graph.resolve()
+ first_blob = graph.resolve()
blobs, order = graph.build_order()
- self.msg('Building %s' % blob)
-
- # build things in this order
- ret.append(builder.build_single(blob, blobs, order))
+ # parse the second blob, if there is one
+ second_blob = None
+ if len(args) >= 3:
+ repo, ref, filename = args[:3]
+ args = args[3:]
+
+ # load the blob manually
+ treeish = source_manager.get_treeish(repo, ref)
+ morphology = morph_loader.load(treeish, filename)
+ second_blob = morphlib.blobs.Blob.create_blob(morphology)
+
+ try:
+ # find the corresponding blob object in the blobs
+ # returned from the dependency graph
+ second_blob = [x for x in blobs if x == second_blob][0]
+ except IndexError:
+ raise cliapp.AppException('%s and %s are unrelated' %
+ (first_blob, second_blob))
+
+ # build the single blob
+ if second_blob:
+ # verify that the two input blobs are valid
+ if first_blob.morph.kind != 'stratum':
+ raise cliapp.AppException('The first tuple %s needs to '
+ 'refer to a stratum' %
+ first_blob)
+ if second_blob.morph.kind != 'chunk':
+ raise cliapp.AppException('The first tuple %s needs to '
+ 'refer to a chunk' % second_blob)
+
+ # build now
+ self.msg('Building %s' % second_blob)
+ ret.append(builder.build_single(second_blob, blobs, order))
+ else:
+ # build the blob now
+ self.msg('Building %s' % first_blob)
+ ret.append(builder.build_single(first_blob, blobs, order))
# we may not have permission to tempdir.remove()
ex = morphlib.execute.Execute('.', lambda msg: None)