From 3bd73dda33fb0669627b642cec6bf1d26b966263 Mon Sep 17 00:00:00 2001 From: Christian Hammond Date: Tue, 3 Nov 2009 01:33:50 -0800 Subject: Fix post-review error reporting when using --diff-only. Running post-review --diff-only may throw exceptions when encountering errors, instead of gracefully handlin them. A simple case of this is to run with --diff-only without having a post-review login cookie, and instead of a login prompt, post-review will crash with a KeyError. This change fixes this reporting by not special-casing the --diff-only parameter in the error reporting. We were only handling errors if that option was not set. Patch by Eric Huss. Reviewed at http://reviews.reviewboard.org/r/1185/ --- rbtools/postreview.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/rbtools/postreview.py b/rbtools/postreview.py index 863c835..567e891 100755 --- a/rbtools/postreview.py +++ b/rbtools/postreview.py @@ -379,14 +379,17 @@ class ReviewBoardServer(object): except APIError, e: rsp, = e.args - if not options.diff_only: - if rsp['err']['code'] == 204: # Change number in use + if rsp['err']['code'] == 204: # Change number in use + if options.diff_only: + # In this case, fall through and return to tempt_fate. + debug("Review request already exists.") + else: debug("Review request already exists. Updating it...") rsp = self.api_post( 'api/json/reviewrequests/%s/update_from_changenum/' % rsp['review_request']['id']) - else: - raise e + else: + raise e debug("Review request created") return rsp['review_request'] -- cgit v1.2.3