From c2104eb199916f9ef7e7b77d0eebf33619ed3ea9 Mon Sep 17 00:00:00 2001 From: Jannis Pohlmann Date: Tue, 31 Jan 2012 16:38:18 +0000 Subject: 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. --- morph | 45 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-) (limited to 'morph') 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) -- cgit v1.2.1