diff options
author | Marcin Cieslak <saper@saper.info> | 2012-10-30 17:42:41 +0100 |
---|---|---|
committer | Jeremy Stanley <fungi@yuggoth.org> | 2012-12-13 22:04:04 +0000 |
commit | 4fbd426c9eac886b2b9c8c9c4ef14d8b1998ad0a (patch) | |
tree | e1d2afa47e489f1212eb9ac0142ba8af21c39e5d | |
parent | 5e83096b8d9982391cfeec33ba403fa65701e990 (diff) | |
download | git-review-4fbd426c9eac886b2b9c8c9c4ef14d8b1998ad0a.tar.gz |
Use exceptions for list_reviews
Add exceptions to errors that might
happend when listing open changes
for review.
Use exit codes 32 and 33 for exceptions.
Change-Id: I8a94fd0e13bbf1dbc9f01ca03a319628ca497d81
-rwxr-xr-x | git-review | 25 | ||||
-rw-r--r-- | git-review.1 | 4 |
2 files changed, 20 insertions, 9 deletions
@@ -520,6 +520,16 @@ def get_topic(target_branch): return branch_name +class CannotQueryOpenChangesets(CommandFailed): + "Cannot fetch review information from gerrit" + EXIT_CODE = 32 + + +class CannotParseOpenChangesets(ChangeSetException): + "Cannot parse JSON review information from gerrit" + EXIT_CODE = 33 + + def list_reviews(remote): (hostname, username, port, project_name) = \ @@ -535,16 +545,12 @@ def list_reviews(remote): userhost = "%s@%s" % (username, hostname) review_info = None - (status, output) = run_command_status( + output = run_command_exc( + CannotQueryOpenChangesets, "ssh", "-x", port, userhost, "gerrit", "query", "--format=JSON project:%s status:open" % project_name) - if status != 0: - print("Could not fetch review information from gerrit") - print(output) - return status - review_list = [] review_field_width = {} REVIEW_FIELDS = ('number', 'branch', 'subject') @@ -569,8 +575,7 @@ def list_reviews(remote): except: if VERBOSE: print(output) - print("Could not parse json query response:", sys.exc_info()[1]) - return 1 + raise(CannotParseOpenChangesets, sys.exc_info()[1]) if 'type' in review_info: break @@ -848,7 +853,9 @@ def main(): download_review(options.download, branch, remote) return elif options.list: - print_exit_message(list_reviews(remote), needs_update) + list_reviews(remote) + return + else: topic = options.topic if topic is None: diff --git a/git-review.1 b/git-review.1 index 711d7bd..8a0c26c 100644 --- a/git-review.1 +++ b/git-review.1 @@ -118,6 +118,10 @@ specific error codes are available: Gerrit .Ar commit-msg hook could not be successfully installed. +.It 32 +Cannot fetch list of open changesets from Gerrit. +.It 33 +Cannot parse list of open changesets received from Gerrit. .It 34 Cannot query information about changesets. .It 35 |