diff options
author | Jannis Pohlmann <jannis.pohlmann@codethink.co.uk> | 2012-04-17 13:36:35 +0100 |
---|---|---|
committer | Jannis Pohlmann <jannis.pohlmann@codethink.co.uk> | 2012-04-17 13:36:35 +0100 |
commit | 46a477336400a8bfd1ff6fc358b74e0d2b4759d0 (patch) | |
tree | f1f7fdc6072284ac01bc5d69a6563a9e0d7b7728 /morphlib/localrepocache.py | |
parent | 75adcd50b5565b45e80688244521702bb6fa6c2a (diff) | |
download | morph-46a477336400a8bfd1ff6fc358b74e0d2b4759d0.tar.gz |
Remember repo objects in LocalRepoCache to always return the same ones.
Diffstat (limited to 'morphlib/localrepocache.py')
-rw-r--r-- | morphlib/localrepocache.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/morphlib/localrepocache.py b/morphlib/localrepocache.py index b6aa272b..27c581aa 100644 --- a/morphlib/localrepocache.py +++ b/morphlib/localrepocache.py @@ -80,6 +80,7 @@ class LocalRepoCache(object): bundle_base_url += '/' # pragma: no cover self._bundle_base_url = bundle_base_url self._ex = morphlib.execute.Execute(cachedir, logging.debug) + self._cached_repo_objects = {} def _exists(self, filename): # pragma: no cover '''Does a file exist? @@ -239,8 +240,14 @@ class LocalRepoCache(object): def get_repo(self, reponame): '''Return an object representing a cached repository.''' - for repourl, path in self._base_iterate(reponame): - if self._exists(path): - return morphlib.cachedrepo.CachedRepo(repourl, path) + if reponame in self._cached_repo_objects: + return self._cached_repo_objects[reponame] + else: + for repourl, path in self._base_iterate(reponame): + if self._exists(path): + repo = morphlib.cachedrepo.CachedRepo( + reponame, repourl, path) + self._cached_repo_objects[reponame] = repo + return repo raise NotCached(reponame) |