summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Hammond <chipx86@chipx86.com>2009-11-03 01:33:50 -0800
committerChristian Hammond <chipx86@chipx86.com>2009-11-03 01:33:50 -0800
commit3bd73dda33fb0669627b642cec6bf1d26b966263 (patch)
treef5a6ec89db640248e055d4a404f370186ce0d8a5
parent5985a3192e52832a5bfb05d7071cb00d93e17c63 (diff)
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/
-rwxr-xr-xrbtools/postreview.py11
1 files 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']