summaryrefslogtreecommitdiff
path: root/morphlib/localrepocache.py
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2014-10-23 17:33:49 +0100
committerSam Thursfield <sam.thursfield@codethink.co.uk>2014-12-03 10:23:27 +0000
commit2dc11594d5b95d876c9997ca40dfb08bf06c830b (patch)
treec2752f38b17e765416dad9ea64688aad0e60d60a /morphlib/localrepocache.py
parentbb1960c7711a8a48bbaabd188158a3c5d7f0ff04 (diff)
downloadmorph-2dc11594d5b95d876c9997ca40dfb08bf06c830b.tar.gz
Rework CachedRepo to use the GitDirectory class where possible
This consolidates a bunch of code paths that were previously duplicated. This also changes the API for local cached repos to match the function names GitDirectory uses. Note that the remote repo cache still uses the old names, and should be fixed when time permits. Some unit tests that use the CachedRepo module required a bit of inelegant monkey-patching in order that they continue to work. A better way to do this would be with the 'mock' library (which would need to be added to Baserock 'build' and 'devel' systems before we could use it).
Diffstat (limited to 'morphlib/localrepocache.py')
-rw-r--r--morphlib/localrepocache.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/morphlib/localrepocache.py b/morphlib/localrepocache.py
index 92c5e763..9bccb20b 100644
--- a/morphlib/localrepocache.py
+++ b/morphlib/localrepocache.py
@@ -225,6 +225,11 @@ class LocalRepoCache(object):
self.fs.rename(target, path)
return self.get_repo(reponame)
+ def _new_cached_repo_instance(self, reponame, repourl,
+ path): # pragma: no cover
+ return morphlib.cachedrepo.CachedRepo(
+ self._app, reponame, repourl, path)
+
def get_repo(self, reponame):
'''Return an object representing a cached repository.'''
@@ -234,8 +239,7 @@ class LocalRepoCache(object):
repourl = self._resolver.pull_url(reponame)
path = self._cache_name(repourl)
if self.fs.exists(path):
- repo = morphlib.cachedrepo.CachedRepo(self._app, reponame,
- repourl, path)
+ repo = self._new_cached_repo_instance(reponame, repourl, path)
self._cached_repo_objects[reponame] = repo
return repo
raise NotCached(reponame)