diff options
author | Christian Hammond <chipx86@chipx86.com> | 2010-03-10 01:12:36 -0800 |
---|---|---|
committer | Christian Hammond <chipx86@chipx86.com> | 2010-03-10 01:12:36 -0800 |
commit | 665c6af5ad344af0d0b17e53ad93af30e9458a34 (patch) | |
tree | 7dbc0011d7cab221afb663ec321e35d3a7c38f25 | |
parent | 84366dbc714224eac0e939eac9c7e4eaf1d157ae (diff) |
Prevent a failure when there's an error reading a diff.
If reading a diff failed and we received a one-line error message,
post-review would crash. It assumed a second line always existed. Now
we properly abort with debug information.
Patch by Laurent Nicolas.
Reviewed at http://reviews.reviewboard.org/r/1457/
-rwxr-xr-x | rbtools/postreview.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/rbtools/postreview.py b/rbtools/postreview.py index d5fa0e0..cff06be 100755 --- a/rbtools/postreview.py +++ b/rbtools/postreview.py @@ -1809,7 +1809,7 @@ class PerforceClient(SCMClient): dl.insert(0, "==== %s#%s ==%s== %s ====\n" % \ (depot_path, base_revision, changetype_short, local_path)) dl.append('\n') - else: + elif len(dl) > 1: m = re.search(r'(\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d)', dl[1]) if m: timestamp = m.group(1) @@ -1847,6 +1847,8 @@ class PerforceClient(SCMClient): # that the resulting diff file isn't broken. if dl[-1][-1] != '\n': dl.append('\n') + else: + die("ERROR, no valid diffs: %s" % dl[0]) return dl |