summaryrefslogtreecommitdiff
path: root/morphlib
diff options
context:
space:
mode:
authorJannis Pohlmann <jannis.pohlmann@codethink.co.uk>2012-02-13 14:53:34 +0000
committerJannis Pohlmann <jannis.pohlmann@codethink.co.uk>2012-02-13 15:00:01 +0000
commitb087899154f10f1c720c99a95cab10f775daba77 (patch)
tree8b9c06d85fabaf4f1fa565b1c7fe2f29ae571854 /morphlib
parentc0a0cf761452be65b81c84671633c510fb4a8cdf (diff)
downloadmorph-b087899154f10f1c720c99a95cab10f775daba77.tar.gz
SourceManager: Do not attempt to fetch bundle if update is false.
If the SourceManager is told to not update repositories, then it should always assume that we have the repo cached for at least one of the base URLs. In that case it should never try to download a bundle from a bundle server and just skip all bundles.
Diffstat (limited to 'morphlib')
-rw-r--r--morphlib/sourcemanager.py89
1 files changed, 48 insertions, 41 deletions
diff --git a/morphlib/sourcemanager.py b/morphlib/sourcemanager.py
index 0f6beb72..45431cb1 100644
--- a/morphlib/sourcemanager.py
+++ b/morphlib/sourcemanager.py
@@ -81,49 +81,56 @@ class SourceManager(object):
self.msg('Cached clone exists, assuming origin is up to date')
return True, location # pragma: no cover
else:
- self.msg('No cached clone found, fetching from %s' % repo)
-
- success = False
-
- bundle = None
- if self.settings['bundle-server']:
- bundle_server = self.settings['bundle-server']
- if not bundle_server.endswith('/'):
- bundle_server += '/'
- self.msg('Using bundle server %s, looking for bundle for %s' %
- (bundle_server, name))
- bundle = name + ".bndl"
- lookup_url = bundle_server + bundle
- self.msg('Checking for bundle %s' % lookup_url)
- req = urllib2.Request(lookup_url)
+ if self.update:
+ self.msg('No cached clone found, fetching from %s' % repo)
+
+ success = False
+
+ bundle = None
+ if self.settings['bundle-server']:
+ bundle_server = self.settings['bundle-server']
+ if not bundle_server.endswith('/'):
+ bundle_server += '/'
+ self.msg('Using bundle server %s, looking for bundle '
+ 'for %s' % (bundle_server, name))
+ bundle = name + ".bndl"
+ lookup_url = bundle_server + bundle
+ self.msg('Checking for bundle %s' % lookup_url)
+ req = urllib2.Request(lookup_url)
- try:
- urllib2.urlopen(req)
- self._wget(lookup_url)
- bundle = self.cache_dir + '/' + bundle
- except urllib2.URLError:
- self.msg('Unable to find bundle %s on %s' %
- (bundle, bundle_server))
- bundle = None
- try:
- if bundle:
- self.msg('Initialising repository at %s' % location)
- os.mkdir(location)
- self.msg('Extracting bundle %s into %s' %
- (bundle, location))
- morphlib.git.extract_bundle(location, bundle, self.msg)
- self.msg('Setting origin to %s' % repo)
- morphlib.git.set_remote(location,'origin', repo, self.msg)
- self.msg('Updating from origin')
try:
- morphlib.git.update_remote(location, "origin", self.msg)
- except morphlib.execute.CommandFailure, e: # pragma: no cover
- logging.warning('Ignoring git failure:\n%s' % str(e))
- else:
- self.msg('Cloning %s into %s' % (repo, location))
- morphlib.git.clone(location, repo, self.msg)
- success = True
- except morphlib.execute.CommandFailure:
+ urllib2.urlopen(req)
+ self._wget(lookup_url)
+ bundle = self.cache_dir + '/' + bundle
+ except urllib2.URLError:
+ self.msg('Unable to find bundle %s on %s' %
+ (bundle, bundle_server))
+ bundle = None
+ try:
+ if bundle:
+ self.msg('Initialising repository at %s' % location)
+ os.mkdir(location)
+ self.msg('Extracting bundle %s into %s' %
+ (bundle, location))
+ morphlib.git.extract_bundle(location, bundle, self.msg)
+ self.msg('Setting origin to %s' % repo)
+ morphlib.git.set_remote(location,'origin', repo,
+ self.msg)
+ self.msg('Updating from origin')
+ try:
+ morphlib.git.update_remote(location, "origin",
+ self.msg)
+ except morphlib.execute.CommandFailure, e: # pragma: no cover
+ logging.warning('Ignoring git failure:\n%s' %
+ str(e))
+ else:
+ self.msg('Cloning %s into %s' % (repo, location))
+ morphlib.git.clone(location, repo, self.msg)
+ success = True
+ except morphlib.execute.CommandFailure:
+ success = False
+ else: # pragma: no cover
+ self.msg('No cached clone found, skipping this location')
success = False
return success, location