OLD | NEW |
1 # coding: utf-8 | 1 # coding: utf-8 |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 """Defines class Rietveld to easily access a rietveld instance. | 5 """Defines class Rietveld to easily access a rietveld instance. |
6 | 6 |
7 Security implications: | 7 Security implications: |
8 | 8 |
9 The following hypothesis are made: | 9 The following hypothesis are made: |
10 - Rietveld enforces: | 10 - Rietveld enforces: |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 svn_props = self.parse_svn_properties( | 129 svn_props = self.parse_svn_properties( |
130 state.get('property_changes', ''), filename) | 130 state.get('property_changes', ''), filename) |
131 | 131 |
132 if state.get('is_binary'): | 132 if state.get('is_binary'): |
133 if status[0] == 'D': | 133 if status[0] == 'D': |
134 if status[0] != status.strip(): | 134 if status[0] != status.strip(): |
135 raise patch.UnsupportedPatchFormat( | 135 raise patch.UnsupportedPatchFormat( |
136 filename, 'Deleted file shouldn\'t have property change.') | 136 filename, 'Deleted file shouldn\'t have property change.') |
137 out.append(patch.FilePatchDelete(filename, state['is_binary'])) | 137 out.append(patch.FilePatchDelete(filename, state['is_binary'])) |
138 else: | 138 else: |
139 out.append(patch.FilePatchBinary( | 139 content = self.get_file_content(issue, patchset, state['id']) |
| 140 if not content: |
| 141 # As a precaution due to a bug in upload.py for git checkout, refuse |
| 142 # empty files. If it's empty, it's not a binary file. |
| 143 raise patch.UnsupportedPatchFormat( |
| 144 filename, |
| 145 'Binary file is empty. Maybe the file wasn\'t uploaded in the ' |
| 146 'first place?') |
| 147 raise patch.UnsupportedPatchFormat( |
140 filename, | 148 filename, |
141 self.get_file_content(issue, patchset, state['id']), | 149 'Binary file support is temporarilly disabled due to a bug. ' |
142 svn_props, | 150 'Please commit blindly the binary files first then commit the ' |
143 is_new=(status[0] == 'A'))) | 151 'source change as a separate CL. Sorry for the annoyance.') |
| 152 #out.append(patch.FilePatchBinary( |
| 153 # filename, |
| 154 # content, |
| 155 # svn_props, |
| 156 # is_new=(status[0] == 'A'))) |
144 continue | 157 continue |
145 | 158 |
146 try: | 159 try: |
147 diff = self.get_file_diff(issue, patchset, state['id']) | 160 diff = self.get_file_diff(issue, patchset, state['id']) |
148 except urllib2.HTTPError, e: | 161 except urllib2.HTTPError, e: |
149 if e.code == 404: | 162 if e.code == 404: |
150 raise patch.UnsupportedPatchFormat( | 163 raise patch.UnsupportedPatchFormat( |
151 filename, 'File doesn\'t have a diff.') | 164 filename, 'File doesn\'t have a diff.') |
152 raise | 165 raise |
153 | 166 |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 if not 'Name or service not known' in e.reason: | 387 if not 'Name or service not known' in e.reason: |
375 # Usually internal GAE flakiness. | 388 # Usually internal GAE flakiness. |
376 raise | 389 raise |
377 # If reaching this line, loop again. Uses a small backoff. | 390 # If reaching this line, loop again. Uses a small backoff. |
378 time.sleep(1+maxtries*2) | 391 time.sleep(1+maxtries*2) |
379 finally: | 392 finally: |
380 upload.ErrorExit = old_error_exit | 393 upload.ErrorExit = old_error_exit |
381 | 394 |
382 # DEPRECATED. | 395 # DEPRECATED. |
383 Send = get | 396 Send = get |
OLD | NEW |