diff --git a/src/mr/developer/common.py b/src/mr/developer/common.py index 6520ec7..b737514 100644 --- a/src/mr/developer/common.py +++ b/src/mr/developer/common.py @@ -168,7 +168,8 @@ def worker(working_copies, the_queue): return try: output = action(**kwargs) - except WCError: + except WCError as e: + threading.current_thread().exc = e output_lock.acquire() for lvl, msg in wc._output: lvl(msg) @@ -259,6 +260,12 @@ def _cleanup(): thread.start() threads.append(thread) for thread in threads: + exc = None + if hasattr(thread, "exc"): + exc = thread.exc + delattr(thread, "exc") + if exc: + raise thread.exc thread.join() if sys.version_info < (2, 6): subprocess._cleanup = _old_subprocess_cleanup diff --git a/src/mr/developer/git.py b/src/mr/developer/git.py index 0ed6fa8..87e7b70 100644 --- a/src/mr/developer/git.py +++ b/src/mr/developer/git.py @@ -199,8 +199,7 @@ def git_switch_branch(self, stdout_in, stderr_in, accept_missing=False): return (stdout_in + stdout, stderr_in + stderr) else: - self.output((logger.error, "No such branch %r", branch)) - sys.exit(1) + raise GitError("No such branch %r" % branch) # runs the checkout with predetermined arguments cmd = self.run_git(argv, cwd=path) stdout, stderr = cmd.communicate() @@ -288,7 +287,10 @@ def matches(self): def update(self, **kwargs): name = self.source['name'] if not self.matches(): - self.output((logger.warning, "Can't update package '%s' because its URL doesn't match." % name)) + message = "Can't update package '%s' because its URL doesn't match." % name + if kwargs.get("force"): + raise GitError(message) + self.output((logger.warning, message)) if self.status() != 'clean' and not kwargs.get('force', False): raise GitError("Can't update package '%s' because it's dirty." % name) return self.git_update(**kwargs)