diff options
author | Jannis Pohlmann <jannis.pohlmann@codethink.co.uk> | 2012-04-18 13:55:32 +0100 |
---|---|---|
committer | Jannis Pohlmann <jannis.pohlmann@codethink.co.uk> | 2012-04-18 13:55:32 +0100 |
commit | 63927c35611bf56a1fce03750e953ec5250fb282 (patch) | |
tree | 76ef3cf6ab81b3fb67cf405828573a3532f02eae /morphcacheserver | |
parent | 9ba282863b41bea8d9fe990a9aba92677e2f4501 (diff) | |
download | morph-63927c35611bf56a1fce03750e953ec5250fb282.tar.gz |
Raise a RepositoryNotFoundError if a repo does not exist in the cache.
Diffstat (limited to 'morphcacheserver')
-rw-r--r-- | morphcacheserver/repocache.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/morphcacheserver/repocache.py b/morphcacheserver/repocache.py index 49b82001..1b6862cb 100644 --- a/morphcacheserver/repocache.py +++ b/morphcacheserver/repocache.py @@ -19,6 +19,13 @@ import os import string +class RepositoryNotFoundError(cliapp.AppException): + + def __init__(self, repo): + cliapp.AppException.__init__( + self, 'Repository %s does not exist in the cache' % repo) + + class InvalidReferenceError(cliapp.AppException): def __init__(self, repo, ref): @@ -44,6 +51,8 @@ class RepoCache(object): def resolve_ref(self, repo_url, ref): quoted_url = self._quote_url(repo_url) repo_dir = os.path.join(self.dirname, quoted_url) + if not os.path.exists(repo_dir): + raise RepositoryNotFoundError(repo_url) try: refs = self._show_ref(repo_dir, ref).split('\n') refs = [x.split() for x in refs if 'origin' in x] @@ -60,9 +69,10 @@ class RepoCache(object): def cat_file(self, repo_url, ref, filename): quoted_url = self._quote_url(repo_url) repo_dir = os.path.join(self.dirname, quoted_url) - if not self._is_valid_sha1(ref): raise UnresolvedNamedReferenceError(repo_url, ref) + if not os.path.exists(repo_dir): + raise RepositoryNotFoundError(repo_url) try: sha1 = self._rev_list(repo_dir, ref).strip() except: |