| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 """Defines class Rietveld to easily access a rietveld instance. | 4 """Defines class Rietveld to easily access a rietveld instance. |
| 5 | 5 |
| 6 Security implications: | 6 Security implications: |
| 7 | 7 |
| 8 The following hypothesis are made: | 8 The following hypothesis are made: |
| 9 - Rietveld enforces: | 9 - Rietveld enforces: |
| 10 - Nobody else than issue owner can upload a patch set | 10 - Nobody else than issue owner can upload a patch set |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 """ | 102 """ |
| 103 url = '/download/issue%s_%s_%s.diff' % (issue, patchset, item) | 103 url = '/download/issue%s_%s_%s.diff' % (issue, patchset, item) |
| 104 return self.get(url) | 104 return self.get(url) |
| 105 | 105 |
| 106 def get_patch(self, issue, patchset): | 106 def get_patch(self, issue, patchset): |
| 107 """Returns a PatchSet object containing the details to apply this patch.""" | 107 """Returns a PatchSet object containing the details to apply this patch.""" |
| 108 props = self.get_patchset_properties(issue, patchset) or {} | 108 props = self.get_patchset_properties(issue, patchset) or {} |
| 109 out = [] | 109 out = [] |
| 110 for filename, state in props.get('files', {}).iteritems(): | 110 for filename, state in props.get('files', {}).iteritems(): |
| 111 logging.debug('%s' % filename) | 111 logging.debug('%s' % filename) |
| 112 status = state.get('status') | 112 # If not status, just assume it's a 'M'. Rietveld often gets it wrong and |
| 113 if not status: | 113 # just has status: null. Oh well. |
| 114 raise patch.UnsupportedPatchFormat( | 114 status = state.get('status') or 'M' |
| 115 filename, 'File\'s status is None, patchset upload is incomplete.') | |
| 116 if status[0] not in ('A', 'D', 'M'): | 115 if status[0] not in ('A', 'D', 'M'): |
| 117 raise patch.UnsupportedPatchFormat( | 116 raise patch.UnsupportedPatchFormat( |
| 118 filename, 'Change with status \'%s\' is not supported.' % status) | 117 filename, 'Change with status \'%s\' is not supported.' % status) |
| 119 | 118 |
| 120 svn_props = self.parse_svn_properties( | 119 svn_props = self.parse_svn_properties( |
| 121 state.get('property_changes', ''), filename) | 120 state.get('property_changes', ''), filename) |
| 122 | 121 |
| 123 if state.get('is_binary'): | 122 if state.get('is_binary'): |
| 124 if status[0] == 'D': | 123 if status[0] == 'D': |
| 125 if status[0] != status.strip(): | 124 if status[0] != status.strip(): |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 if not 'Name or service not known' in e.reason: | 331 if not 'Name or service not known' in e.reason: |
| 333 # Usually internal GAE flakiness. | 332 # Usually internal GAE flakiness. |
| 334 raise | 333 raise |
| 335 # If reaching this line, loop again. Uses a small backoff. | 334 # If reaching this line, loop again. Uses a small backoff. |
| 336 time.sleep(1+maxtries*2) | 335 time.sleep(1+maxtries*2) |
| 337 finally: | 336 finally: |
| 338 upload.ErrorExit = old_error_exit | 337 upload.ErrorExit = old_error_exit |
| 339 | 338 |
| 340 # DEPRECATED. | 339 # DEPRECATED. |
| 341 Send = get | 340 Send = get |
| OLD | NEW |