OLD | NEW |
1 # coding=utf8 | 1 # coding=utf8 |
2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2010 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 """Commit queue manager class. | 5 """Commit queue manager class. |
6 | 6 |
7 Security implications: | 7 Security implications: |
8 | 8 |
9 The following hypothesis are made: | 9 The following hypothesis are made: |
10 - Commit queue: | 10 - Commit queue: |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 if message: | 258 if message: |
259 self.rietveld.add_comment(pending.issue, message) | 259 self.rietveld.add_comment(pending.issue, message) |
260 try: | 260 try: |
261 self.queue.pending_commits.remove(pending) | 261 self.queue.pending_commits.remove(pending) |
262 except ValueError: | 262 except ValueError: |
263 pass | 263 pass |
264 | 264 |
265 def _apply_patch(self, pending, revision): | 265 def _apply_patch(self, pending, revision): |
266 """Applies the pending patch to the checkout and throws if it fails.""" | 266 """Applies the pending patch to the checkout and throws if it fails.""" |
267 patch_data = urllib2.urlopen(pending.patch_url()).read() | 267 patch_data = urllib2.urlopen(pending.patch_url()).read() |
| 268 error = patch.verify_patch(patch_data) |
| 269 if error: |
| 270 raise base.DiscardPending(pending, 'Can\'t process patch: %s' % error) |
268 patch_data = patch.auto_mangle_git_patch(patch_data) | 271 patch_data = patch.auto_mangle_git_patch(patch_data) |
269 if not self.checkout.apply_patch(patch_data): | 272 if not self.checkout.apply_patch(patch_data): |
270 raise base.DiscardPending(pending, | 273 raise base.DiscardPending(pending, |
271 'Patch failed to apply against %s.' % revision) | 274 'Patch failed to apply against %s.' % revision) |
272 | 275 |
273 def load(self, filename): | 276 def load(self, filename): |
274 """Loads the commit queue state from a JSON file.""" | 277 """Loads the commit queue state from a JSON file.""" |
275 self.queue = model.load_from_json_file(filename) | 278 self.queue = model.load_from_json_file(filename) |
276 self.queue.pending_commits = self.queue.pending_commits or [] | 279 self.queue.pending_commits = self.queue.pending_commits or [] |
277 | 280 |
278 def save(self, filename): | 281 def save(self, filename): |
279 """Save the commit queue state in a simple JSON file.""" | 282 """Save the commit queue state in a simple JSON file.""" |
280 model.save_to_json_file(filename, self.queue) | 283 model.save_to_json_file(filename, self.queue) |
OLD | NEW |