From 5e2a58f87ed1bfa82796a2b9191b4341913901c4 Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Sat, 14 Jun 2014 19:06:42 +0100 Subject: Raise exception if a ref is not valid in the remote repo cache Previously if a ref didn't resolve in the remote cache, we'd clone the repo into the local cache and check again. However, 99% of the time the clone comes from the remote cache so we should be able to assume that if the ref doesn't exist there, it doesn't exist at all. --- morphlib/app.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/morphlib/app.py b/morphlib/app.py index 7899ae29..43567360 100644 --- a/morphlib/app.py +++ b/morphlib/app.py @@ -21,6 +21,7 @@ import os import re import sys import time +import urllib2 import urlparse import warnings import extensions @@ -331,13 +332,12 @@ class Morph(cliapp.Application): elif rrc is not None: try: absref, tree = rrc.resolve_ref(reponame, ref) - if absref is not None: - self.status(msg='Resolved %(reponame)s %(ref)s via remote ' - 'repo cache', - reponame=reponame, - ref=ref, - chatty=True) - except BaseException, e: + self.status(msg='Resolved %(reponame)s %(ref)s via remote ' + 'repo cache', + reponame=reponame, + ref=ref, + chatty=True) + except urllib2.URLError as e: logging.warning('Caught (and ignored) exception: %s' % str(e)) if absref is None: if update: -- cgit v1.2.1