diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2012-04-09 19:41:39 +0100 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2012-04-09 19:41:39 +0100 |
commit | c3d3e041382d3784c8007ce1b93d431ba575654e (patch) | |
tree | a3135b66828cddf6f8076f550e5de35bb6eccff2 | |
parent | dd3209077785de564eb051c7edbb24a27aa1d0e0 (diff) | |
download | morph-c3d3e041382d3784c8007ce1b93d431ba575654e.tar.gz |
Rewrite "morph update-gits" to use the new repo caching and morphology classes
The code is now longer, but it's more explicit what happens, and it'll
be easier, later on, to add a progress bar.
-rwxr-xr-x | morph | 33 |
1 files changed, 24 insertions, 9 deletions
@@ -17,6 +17,7 @@ import cliapp +import collections import json import logging import os @@ -221,15 +222,29 @@ class Morph(cliapp.Application): ''' - morph_loader = MorphologyLoader(self.settings) - source_manager = morphlib.sourcemanager.SourceManager(self) - - for repo, ref, filename in self._itertriplets(args): - # resolve the dependency graph, which will implicitly - # clone all repositories needed to build the blob - graph = BuildDependencyGraph(source_manager, morph_loader, - repo, ref, filename) - graph.resolve() + cachedir = self.settings['cachedir'] + baseurls = self.settings['git-base-url'] + cache = LocalRepoCache(cachedir, baseurls) + + # Reverse so we process things in the order given by the user. + queue = collections.deque(self._itertriplets(args)) + + while queue: + repo, ref, filename = queue.popleft() + cache.cache_repo(repo) + repo = cache.get_repo(repo) + 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((repo, ref, '%s.morph' % stratum)) + elif morphology['kind'] == 'stratum': + for stratum in morphology['build-depends']: + queue.append((repo, ref, '%s.morph' % stratum)) + for x in morphology['sources']: + queue.append((x.repo, x.ref, x.morph)) def cmd_build_single(self, args): '''Build a binary from a morphology but do not build its dependencies. |