summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Ipsum <richard.ipsum@codethink.co.uk>2015-03-07 17:48:32 +0000
committerRichard Ipsum <richard.ipsum@codethink.co.uk>2015-03-07 21:23:55 +0000
commit364455436aded34ce6f843dfa68a32c14aaf01ea (patch)
treef85decad6ca6929197653cbb991473792e14f0a5
parent11559bbbd24c218d512d503df27157668b37bdc9 (diff)
downloadmorph-364455436aded34ce6f843dfa68a32c14aaf01ea.tar.gz
Fix bug in build system cache access
This fixes a bug that causes morph to run build system detection even though the build system has already been cached. The cache is accessed before the key has been computed (absref isn't known until after we've called resolve_ref) so it always misses.
-rw-r--r--morphlib/sourceresolver.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/morphlib/sourceresolver.py b/morphlib/sourceresolver.py
index 387d2e0d..9255c2de 100644
--- a/morphlib/sourceresolver.py
+++ b/morphlib/sourceresolver.py
@@ -185,6 +185,8 @@ class SourceResolver(object):
reponame, ref)
return ref, self._resolved_trees[(reponame, ref)]
+ logging.debug('tree (%s, %s) not in cache', reponame, ref)
+
absref = None
if self.lrc.has_repo(reponame):
repo = self.lrc.get_repo(reponame)
@@ -428,9 +430,6 @@ class SourceResolver(object):
morphology = self._get_morphology(*definition_key)
buildsystem = None
- if chunk_key in self._resolved_buildsystems:
- buildsystem = self._resolved_buildsystems[chunk_key]
-
if morphology is None and buildsystem is None:
# This is a slow operation (looking for a file in Git repo may
# potentially require cloning the whole thing).
@@ -438,12 +437,21 @@ class SourceResolver(object):
chunk_key = (chunk_repo, absref, filename)
morphology = self._get_morphology(*chunk_key)
+ if chunk_key in self._resolved_buildsystems:
+ logging.debug('Build system for %s is cached', str(chunk_key))
+ self.status(msg='Build system for %s is cached' % str(chunk_key),
+ chatty=True)
+ buildsystem = self._resolved_buildsystems[chunk_key]
+
if morphology is None:
if buildsystem is None:
buildsystem = self._detect_build_system(*chunk_key)
+
if buildsystem is None:
raise MorphologyNotFoundError(filename)
else:
+ logging.debug('Caching build system for chunk with key %s',
+ chunk_key)
self._resolved_buildsystems[chunk_key] = buildsystem
morphology = self._create_morphology_for_build_system(
buildsystem, morph_name)