summaryrefslogtreecommitdiff
path: root/morphlib/localrepocache.py
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2012-04-11 15:16:31 +0100
committerRichard Maw <richard.maw@codethink.co.uk>2012-04-11 15:16:31 +0100
commit5c65f5beb43e83ad2336fc717fb35d10c5d18976 (patch)
tree4ea6224b2f94b1b8fc9776ca9bf3deabea28349c /morphlib/localrepocache.py
parent5cdd2996ef74c7792d4ad85db985886228e00cbf (diff)
downloadmorph-5c65f5beb43e83ad2336fc717fb35d10c5d18976.tar.gz
localrepocache: return repo after cloning
Diffstat (limited to 'morphlib/localrepocache.py')
-rw-r--r--morphlib/localrepocache.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/morphlib/localrepocache.py b/morphlib/localrepocache.py
index 4401d9c5..b6aa272b 100644
--- a/morphlib/localrepocache.py
+++ b/morphlib/localrepocache.py
@@ -44,6 +44,12 @@ class NoRemote(Exception):
return '\n\t'.join(['Cannot find remote git repository: %s' %
self.reponame] + self.errors)
+class NotCached(Exception):
+ def __init__(self, reponame):
+ self.reponame = reponame
+
+ def __str__(self): # pragma: no cover
+ return 'Repository %s is not cached yet' % self.reponame
class LocalRepoCache(object):
@@ -204,15 +210,16 @@ class LocalRepoCache(object):
if not self._exists(self._cachedir):
self._mkdir(self._cachedir)
- for repourl, path in self._base_iterate(reponame):
- if self._exists(path):
- return
+ try:
+ return self.get_repo(reponame)
+ except NotCached, e:
+ pass
if self._bundle_base_url:
for repourl, path in self._base_iterate(reponame):
ok, error = self._clone_with_bundle(repourl, path)
if ok:
- return
+ return self.get_repo(reponame)
else:
errors.append(error)
@@ -227,11 +234,13 @@ class LocalRepoCache(object):
else:
raise NoRemote(reponame, errors)
+ return self.get_repo(reponame)
+
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)
- raise Exception('Repository %s is not cached yet' % reponame)
+ raise NotCached(reponame)