diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2012-04-10 12:37:29 +0100 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2012-04-10 12:37:29 +0100 |
commit | b1c6d2e4069ad466e8982236f4ca8611b24040cb (patch) | |
tree | 4aa77ee9f1540e5c67295f14fe3258add75bc1e1 /morphlib/localrepocache.py | |
parent | 73d03fb9de4dc1b7ce240076f0e0e81772373953 (diff) | |
download | morph-b1c6d2e4069ad466e8982236f4ca8611b24040cb.tar.gz |
Fix unit test failures: mark out-of-coverage, and use wrapper to allow tests
The self._exists method needs to be used instead of raw os.path.exists,
so that unit tests can override it easily.
Also, a tiny clarification so that the caller of _clone_with_bundle
decides whether it's OK to try to download a bundle.
Diffstat (limited to 'morphlib/localrepocache.py')
-rw-r--r-- | morphlib/localrepocache.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/morphlib/localrepocache.py b/morphlib/localrepocache.py index 6587a0e5..9aef13e4 100644 --- a/morphlib/localrepocache.py +++ b/morphlib/localrepocache.py @@ -68,7 +68,7 @@ class LocalRepoCache(object): self._cachedir = cachedir self._baseurls = baseurls if bundle_base_url and not bundle_base_url.endswith('/'): - bundle_base_url += '/' + bundle_base_url += '/' # pragma: no cover self._bundle_base_url = bundle_base_url self._ex = morphlib.execute.Execute(cachedir, logging.debug) @@ -141,7 +141,7 @@ class LocalRepoCache(object): def _base_iterate(self, reponame): for baseurl in self._baseurls: if not baseurl.endswith('/'): - baseurl += '/' + baseurl += '/' # pragma: no cover repourl = urlparse.urljoin(baseurl, reponame) path = self._cache_name(repourl) yield repourl, path @@ -154,15 +154,13 @@ class LocalRepoCache(object): return False def _clone_with_bundle(self, repourl, path): - if not self._bundle_base_url: - return False escaped = self._escape(repourl) bundle_url = urlparse.urljoin(self._bundle_base_url, escaped) bundle_path = path + '.bundle' success = self._fetch(bundle_url, bundle_path) if success: self._git(['clone', bundle_path, path]) - if os.path.exists(bundle_path): + if self._exists(bundle_path): self._remove(bundle_path) return success @@ -177,7 +175,8 @@ class LocalRepoCache(object): if self._exists(path): break - if self._clone_with_bundle(repourl, path): + if (self._bundle_base_url and + self._clone_with_bundle(repourl, path)): break try: |