OLD | NEW |
1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2011 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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 raise patch.UnsupportedPatchFormat( | 191 raise patch.UnsupportedPatchFormat( |
192 filename, 'Failed to parse svn properties.') | 192 filename, 'Failed to parse svn properties.') |
193 | 193 |
194 while rietveld_svn_props: | 194 while rietveld_svn_props: |
195 # Something like 'Added: svn:eol-style'. Note the action is localized. | 195 # Something like 'Added: svn:eol-style'. Note the action is localized. |
196 # *sigh*. | 196 # *sigh*. |
197 action = rietveld_svn_props.pop(0) | 197 action = rietveld_svn_props.pop(0) |
198 match = re.match(r'^(\w+): (.+)$', action) | 198 match = re.match(r'^(\w+): (.+)$', action) |
199 if not match or not rietveld_svn_props: | 199 if not match or not rietveld_svn_props: |
200 raise patch.UnsupportedPatchFormat( | 200 raise patch.UnsupportedPatchFormat( |
201 filename, 'Failed to parse svn properties.') | 201 filename, |
| 202 'Failed to parse svn properties: %s, %s' % (action, svn_props)) |
202 | 203 |
203 if match.group(2) == 'svn:mergeinfo': | 204 if match.group(2) == 'svn:mergeinfo': |
204 # Silently ignore the content. | 205 # Silently ignore the content. |
205 rietveld_svn_props.pop(0) | 206 rietveld_svn_props.pop(0) |
206 continue | 207 continue |
207 | 208 |
208 if match.group(1) not in ('Added', 'Modified'): | 209 if match.group(1) not in ('Added', 'Modified'): |
209 # Will fail for our French friends. | 210 # Will fail for our French friends. |
210 raise patch.UnsupportedPatchFormat( | 211 raise patch.UnsupportedPatchFormat( |
211 filename, 'Unsupported svn property operation.') | 212 filename, 'Unsupported svn property operation.') |
212 | 213 |
213 if match.group(2) in ('svn:eol-style', 'svn:executable'): | 214 if match.group(2) in ('svn:eol-style', 'svn:executable', 'svn:mime-type'): |
214 # ' + foo' where foo is the new value. That's fragile. | 215 # ' + foo' where foo is the new value. That's fragile. |
215 content = rietveld_svn_props.pop(0) | 216 content = rietveld_svn_props.pop(0) |
216 match2 = re.match(r'^ \+ (.*)$', content) | 217 match2 = re.match(r'^ \+ (.*)$', content) |
217 if not match2: | 218 if not match2: |
218 raise patch.UnsupportedPatchFormat( | 219 raise patch.UnsupportedPatchFormat( |
219 filename, 'Unsupported svn property format.') | 220 filename, 'Unsupported svn property format.') |
220 svn_props.append((match.group(2), match2.group(1))) | 221 svn_props.append((match.group(2), match2.group(1))) |
221 return svn_props | 222 return svn_props |
222 | 223 |
223 def update_description(self, issue, description): | 224 def update_description(self, issue, description): |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 if retry >= (maxtries - 1): | 328 if retry >= (maxtries - 1): |
328 raise | 329 raise |
329 if not 'Name or service not known' in e.reason: | 330 if not 'Name or service not known' in e.reason: |
330 # Usually internal GAE flakiness. | 331 # Usually internal GAE flakiness. |
331 raise | 332 raise |
332 # If reaching this line, loop again. Uses a small backoff. | 333 # If reaching this line, loop again. Uses a small backoff. |
333 time.sleep(1+maxtries*2) | 334 time.sleep(1+maxtries*2) |
334 | 335 |
335 # DEPRECATED. | 336 # DEPRECATED. |
336 Send = get | 337 Send = get |
OLD | NEW |