diff options
author | Jannis Pohlmann <jannis.pohlmann@codethink.co.uk> | 2012-05-04 16:44:35 +0000 |
---|---|---|
committer | Jannis Pohlmann <jannis.pohlmann@codethink.co.uk> | 2012-05-04 16:44:35 +0000 |
commit | 57943a7f49b5c5e01c30fed7a4f013ab32876bc7 (patch) | |
tree | bbb4e2b29e5322327d1c6cf28804bd93b77afed3 /morphlib | |
parent | f3b377ab6ba580dc5eda28b3e53024b841226bd0 (diff) | |
download | morph-57943a7f49b5c5e01c30fed7a4f013ab32876bc7.tar.gz |
Make RemoteRepoCache work with the RepoAliasResolver.
Diffstat (limited to 'morphlib')
-rw-r--r-- | morphlib/remoterepocache.py | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/morphlib/remoterepocache.py b/morphlib/remoterepocache.py index c80a6ae0..39e671eb 100644 --- a/morphlib/remoterepocache.py +++ b/morphlib/remoterepocache.py @@ -38,32 +38,23 @@ class CatFileError(cliapp.AppException): class RemoteRepoCache(object): - def __init__(self, server_url, base_urls): + def __init__(self, server_url, resolver): self.server_url = server_url - self._base_urls = base_urls - - def _base_iterate(self, repo_name): - for base_url in self._base_urls: - if not base_url.endswith('/'): - base_url += '/' - repo_url = urlparse.urljoin(base_url, repo_name) - yield repo_url + self._resolver = resolver def resolve_ref(self, repo_name, ref): - for repo_url in self._base_iterate(repo_name): - try: - return self._resolve_ref_for_repo_url(repo_url, ref) - except: - pass - raise ResolveRefError(repo_name, ref) + repo_url = self._resolver.pull_url(repo_name) + try: + return self._resolve_ref_for_repo_url(repo_url, ref) + except: + raise ResolveRefError(repo_name, ref) def cat_file(self, repo_name, ref, filename): - for repo_url in self._base_iterate(repo_name): - try: - return self._cat_file_for_repo_url(repo_url, ref, filename) - except: - pass - raise CatFileError(repo_name, ref, filename) + repo_url = self._resolver.pull_url(repo_name) + try: + return self._cat_file_for_repo_url(repo_url, ref, filename) + except: + raise CatFileError(repo_name, ref, filename) def _resolve_ref_for_repo_url(self, repo_url, ref): # pragma: no cover data = self._make_request('sha1s?repo=%s&ref=%s' % (repo_url, ref)) |