summaryrefslogtreecommitdiff
path: root/morphlib/cachedrepo.py
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2012-09-13 18:56:35 +0100
committerSam Thursfield <sam.thursfield@codethink.co.uk>2012-09-13 18:57:17 +0100
commit9c786c1ec409724f1331c0fec5ba7a0e98732e24 (patch)
tree46295306079710d9a1d70b867448b7669b3b4548 /morphlib/cachedrepo.py
parent9e95e4a72d875d201dfdb012f217181788eec7f1 (diff)
downloadmorph-9c786c1ec409724f1331c0fec5ba7a0e98732e24.tar.gz
Give more useful errors when cloning from local cache fails
Diffstat (limited to 'morphlib/cachedrepo.py')
-rw-r--r--morphlib/cachedrepo.py27
1 files changed, 19 insertions, 8 deletions
diff --git a/morphlib/cachedrepo.py b/morphlib/cachedrepo.py
index eef49ffb..ad17785a 100644
--- a/morphlib/cachedrepo.py
+++ b/morphlib/cachedrepo.py
@@ -44,12 +44,20 @@ class CheckoutDirectoryExistsError(cliapp.AppException):
(target_dir, repo))
+class CloneError(cliapp.AppException):
+
+ def __init__(self, repo, target_dir):
+ cliapp.AppException.__init__(
+ self,
+ 'Failed to copy %s into %s' % (repo.original_name, target_dir))
+
+
class CheckoutError(cliapp.AppException):
def __init__(self, repo, ref, target_dir):
cliapp.AppException.__init__(
self,
- 'Failed to check out %s:%s into %s' % (repo, ref, target_dir))
+ 'Failed to check out ref %s in %s' % (ref, target_dir))
class UpdateError(cliapp.AppException):
@@ -154,11 +162,8 @@ class CachedRepo(object):
os.mkdir(target_dir)
- try:
- self._copy_repository(self.path, target_dir)
- self._checkout_ref(ref, target_dir)
- except cliapp.AppException:
- raise CheckoutError(self, ref, target_dir)
+ self._copy_repository(self.path, target_dir)
+ self._checkout_ref(ref, target_dir)
def ls_tree(self, ref):
'''Return file names found in root tree. Does not recurse to subtrees.
@@ -215,10 +220,16 @@ class CachedRepo(object):
'%s:%s' % (ref, filename)])
def _copy_repository(self, source_dir, target_dir): # pragma: no cover
- morphlib.git.copy_repository(self._runcmd, source_dir, target_dir)
+ try:
+ morphlib.git.copy_repository(self._runcmd, source_dir, target_dir)
+ except cliapp.AppException:
+ raise CloneError(self, target_dir)
def _checkout_ref(self, ref, target_dir): # pragma: no cover
- morphlib.git.checkout_ref(self._runcmd, target_dir, ref)
+ try:
+ morphlib.git.checkout_ref(self._runcmd, target_dir, ref)
+ except cliapp.AppException:
+ raise CheckoutError(self, ref, target_dir)
def _update(self): # pragma: no cover
self._runcmd(['git', 'remote', 'update', 'origin'])