summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Coldrick <adam.coldrick@codethink.co.uk>2014-04-04 10:42:06 +0000
committerAdam Coldrick <adam.coldrick@codethink.co.uk>2014-04-15 09:20:26 +0000
commitbe111f6e8009523e908c17cc5d2ad396420bf847 (patch)
tree7cdcfadca4fcf9bfdb8f073442ba09850644b34c
parent0baae51e217f4999c1f068c458527d598284ddec (diff)
downloadmorph-be111f6e8009523e908c17cc5d2ad396420bf847.tar.gz
Make morph load chunk morphologies from definitions
Rather than traversing chunk triplets using the source repo and ref, use the definitions repository and add the correct triplet to the source pool using the repo and ref from the chunk morphology.
-rw-r--r--morphlib/app.py25
1 files changed, 23 insertions, 2 deletions
diff --git a/morphlib/app.py b/morphlib/app.py
index 91647a32..e7093698 100644
--- a/morphlib/app.py
+++ b/morphlib/app.py
@@ -26,6 +26,7 @@ import extensions
import morphlib
+
class InvalidUrlError(cliapp.AppException):
def __init__(self, parameter, url):
@@ -33,6 +34,12 @@ class InvalidUrlError(cliapp.AppException):
self, 'Value %s for argument %s is not a url' %
(url, parameter))
+
+class ChunkMorphologyDefinitionError(cliapp.AppException):
+
+ def __init__(self, message):
+ cliapp.AppException.__init__(self, message)
+
defaults = {
'trove-host': 'git.baserock.org',
'trove-id': [],
@@ -286,6 +293,14 @@ class Morph(cliapp.Application):
pool = morphlib.sourcepool.SourcePool()
def add_to_pool(reponame, ref, filename, absref, tree, morphology):
+ if morphology['kind'] == 'chunk':
+ reponame = morphology.get('repo')
+ ref = morphology.get('ref')
+ if not (reponame or ref) and morphology['kind'] == 'chunk':
+ raise ChunkMorphologyDefinitionError(
+ 'Chunk morphology %s lacks a repo and/or ref.' %
+ morphology.get('morph'))
+
source = morphlib.source.Source(reponame, ref, absref, tree,
morphology, filename)
pool.add(source)
@@ -359,7 +374,11 @@ class Morph(cliapp.Application):
resolved_morphologies[reference] = \
morph_factory.get_morphology(reponame, absref, filename)
morphology = resolved_morphologies[reference]
-
+ if morphology['kind'] == 'chunk':
+ update_repo = update and morphology['repo'] not in updated_repos
+ absref, tree = self.resolve_ref(
+ lrc, rrc, morphology['repo'], morphology['ref'], update_repo)
+ updated_repos.add(morphology['repo'])
visit(reponame, ref, filename, absref, tree, morphology)
if morphology['kind'] == 'cluster':
raise cliapp.AppException(
@@ -375,7 +394,9 @@ class Morph(cliapp.Application):
s.get('ref') or ref,
'%s.morph' % s['morph'])
for s in morphology['build-depends'])
- queue.extend((c['repo'], c['ref'], '%s.morph' % c['morph'])
+ queue.extend((reponame,
+ ref,
+ '%s.morph' % c['morph'])
for c in morphology['chunks'])
def cache_repo_and_submodules(self, cache, url, ref, done):