diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2012-04-11 10:24:31 +0100 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2012-04-11 13:10:27 +0100 |
commit | 38132bcc37534d9d7727a7e93f2113a6b4e3acd5 (patch) | |
tree | c046abb318cb07d44682a4f0ab140e9c8c934514 /morphlib/localrepocache.py | |
parent | 12fe72e696a57624c123aa0ed552809c633b2942 (diff) | |
download | morph-38132bcc37534d9d7727a7e93f2113a6b4e3acd5.tar.gz |
localrepocache: fixes to remote set-url
It needed shutil, but that exception was being missed.
_git needs to be able to handle a different current directory for
remote set-url to work
Diffstat (limited to 'morphlib/localrepocache.py')
-rw-r--r-- | morphlib/localrepocache.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/morphlib/localrepocache.py b/morphlib/localrepocache.py index ee919582..4401d9c5 100644 --- a/morphlib/localrepocache.py +++ b/morphlib/localrepocache.py @@ -18,6 +18,7 @@ import logging import os import urllib2 import urlparse +import shutil import morphlib @@ -84,7 +85,7 @@ class LocalRepoCache(object): return os.path.exists(filename) - def _git(self, args): # pragma: no cover + def _git(self, args, cwd=None): # pragma: no cover '''Execute git command. This is a method of its own so that unit tests can easily override @@ -92,7 +93,7 @@ class LocalRepoCache(object): ''' - self._ex.runv(['git'] + args) + self._ex.runv(['git'] + args, cwd=cwd) def _fetch(self, url, filename): # pragma: no cover '''Fetch contents of url into a file. @@ -174,13 +175,15 @@ class LocalRepoCache(object): escaped = self._escape(repourl) bundle_url = urlparse.urljoin(self._bundle_base_url, escaped) + '.bndl' bundle_path = path + '.bundle' + try: self._fetch(bundle_url, bundle_path) except urllib2.URLError, e: return False, 'Unable to fetch bundle %s: %s' % (bundle_url, e) + try: self._git(['clone', bundle_path, path]) - self._git(['remote', 'set-url', 'origin', repourl]) + self._git(['remote', 'set-url', 'origin', repourl], cwd=path) except morphlib.execute.CommandFailure, e: # pragma: no cover if self._exists(path): shutil.rmtree(path) |