From 364455436aded34ce6f843dfa68a32c14aaf01ea Mon Sep 17 00:00:00 2001 From: Richard Ipsum Date: Sat, 7 Mar 2015 17:48:32 +0000 Subject: 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. --- morphlib/sourceresolver.py | 14 +++++++++++--- 1 file 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) -- cgit v1.2.1