From 665c6af5ad344af0d0b17e53ad93af30e9458a34 Mon Sep 17 00:00:00 2001 From: Christian Hammond Date: Wed, 10 Mar 2010 01:12:36 -0800 Subject: 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/ --- rbtools/postreview.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3