From 2dc11594d5b95d876c9997ca40dfb08bf06c830b Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Thu, 23 Oct 2014 17:33:49 +0100 Subject: 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). --- morphlib/morphologyfactory.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'morphlib/morphologyfactory.py') diff --git a/morphlib/morphologyfactory.py b/morphlib/morphologyfactory.py index dad7238e..a3ac2749 100644 --- a/morphlib/morphologyfactory.py +++ b/morphlib/morphologyfactory.py @@ -57,10 +57,11 @@ class MorphologyFactory(object): chatty=True) try: repo = self._lrc.get_repo(reponame) - morph = loader.load_from_string(repo.cat(sha1, filename)) + text = repo.read_file(filename, sha1) + morph = loader.load_from_string(text) except IOError: morph = None - file_list = repo.ls_tree(sha1) + file_list = repo.list_files(ref=sha1, recurse=False) elif self._rrc is not None: self.status(msg="Retrieving %(reponame)s %(sha1)s %(filename)s" " from the remote git cache.", -- cgit v1.2.1