diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2012-04-11 15:39:19 +0100 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2012-04-11 15:39:19 +0100 |
commit | aee0ea379380c7007f8220a251c9d1da7cfb7de8 (patch) | |
tree | b78b520b9654d13cdbc404852bc63f88b0afc47d /morph | |
parent | aad418511a48fe1fdbc89aacd0ff0f66d68022a9 (diff) | |
download | morph-aee0ea379380c7007f8220a251c9d1da7cfb7de8.tar.gz |
show-dependencies: use BuildGraph and Sourcepool
Rather than rely on the magic SourceManager, traverse the morphologies
to list the sources, then create the dependency groups and print them
Diffstat (limited to 'morph')
-rwxr-xr-x | morph | 68 |
1 files changed, 46 insertions, 22 deletions
@@ -189,30 +189,54 @@ class Morph(cliapp.Application): def cmd_show_dependencies(self, args): '''Dumps the dependency tree of all input morphologies.''' - morph_loader = MorphologyLoader(self.settings) - source_manager = morphlib.sourcemanager.SourceManager(self, - update=not self.settings['no-git-update']) + graph = morphlib.buildgraph.BuildGraph() + pool = morphlib.sourcepool.SourcePool() - for repo, ref, filename in self._itertriplets(args): - # create a dependency graph for the morphology - graph = BuildDependencyGraph(source_manager, morph_loader, - repo, ref, filename) - graph.resolve() - - # print the graph - self.output.write('dependency tree:\n') - for blob in sorted(graph.blobs, key=str): - self.output.write(' %s\n' % blob) - for dependency in sorted(blob.dependencies, key=str): - self.output.write(' -> %s\n' % dependency) + if not os.path.exists(self.settings['cachedir']): + os.mkdir(self.settings['cachedir']) + cachedir = os.path.join(self.settings['cachedir'], 'gits') + baseurls = self.settings['git-base-url'] + bundle_base_url = self.settings['bundle-server'] + cache = morphlib.localrepocache.LocalRepoCache( + cachedir, baseurls, bundle_base_url) - # compute a build order from the graph - blobs, order = graph.build_order() - self.output.write('build order:\n') - for group in order: - self.output.write(' group:\n') - for blob in sorted(group, key=str): - self.output.write(' %s\n' % blob) + # traverse the morphs to list all the sources + queue = collections.deque(self._itertriplets(args)) + while queue: + reponame, ref, filename = queue.popleft() + if self.settings['no-git-update']: + repo = cache.get_repo(reponame) + else: + repo = cache.cache_repo(reponame) + repo.update() + absref = repo.resolve_ref(ref) + text = repo.cat(absref, filename) + morphology = morphlib.morph2.Morphology(text) + if morphology['kind'] == 'system': + for stratum in morphology['strata']: + queue.append((reponame, ref, '%s.morph' % stratum)) + elif morphology['kind'] == 'stratum': + if morphology['build-depends']: + for stratum in morphology['build-depends']: + queue.append((reponame, ref, '%s.morph' % stratum)) + for x in morphology['sources']: + queue.append((x['repo'], x['ref'], + '%s.morph' % x['morph'])) + source = morphlib.source.Source(reponame, ref, absref, + morphology, filename) + pool.add(source) + + order = graph.compute_build_order(pool) + self.output.write('dependency tree:\n') + for source in sorted(pool, key=str): + self.output.write(' %s\n' % source) + for dependency in sorted(source.dependencies, key=str): + self.output.write(' -> %s\n' % dependency) + self.output.write('build order:\n') + for group in order: + self.output.write(' group:\n') + for source in group: + self.output.write(' %s\n' % source) def cmd_update_gits(self, args): '''Update cached git repositories. |