OLD | NEW |
1 # coding=utf8 | 1 # coding=utf8 |
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 """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 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 'revision': pending.revision, | 537 'revision': pending.revision, |
538 'output': msg, | 538 'output': msg, |
539 'url': viewvc_url}}) | 539 'url': viewvc_url}}) |
540 | 540 |
541 # Closes the issue on Rietveld. | 541 # Closes the issue on Rietveld. |
542 # TODO(csharp): Retry if exceptions are encountered. | 542 # TODO(csharp): Retry if exceptions are encountered. |
543 try: | 543 try: |
544 self.context.rietveld.close_issue(pending.issue) | 544 self.context.rietveld.close_issue(pending.issue) |
545 self.context.rietveld.update_description( | 545 self.context.rietveld.update_description( |
546 pending.issue, issue_desc.description) | 546 pending.issue, issue_desc.description) |
| 547 self.context.rietveld.add_comment( |
| 548 pending.issue, 'Change committed as %s' % pending.revision) |
547 except (urllib2.HTTPError, urllib2.URLError) as e: | 549 except (urllib2.HTTPError, urllib2.URLError) as e: |
548 # Ignore AppEngine flakiness. | 550 # Ignore AppEngine flakiness. |
549 logging.warning('Unable to fully close the issue') | 551 logging.warning('Unable to fully close the issue') |
550 self._discard_pending(pending, | 552 # And finally remove the issue. If the close_issue() call above failed, |
551 'Change committed as %s' % pending.revision) | 553 # it is possible the dashboard will be confused but it is harmless. |
| 554 try: |
| 555 self.queue.get(pending.issue) |
| 556 except KeyError: |
| 557 logging.error('Internal inconsistency for %d', pending.issue) |
| 558 self.queue.remove(pending.issue) |
552 except ( | 559 except ( |
553 checkout.PatchApplicationFailed, patch.UnsupportedPatchFormat) as e: | 560 checkout.PatchApplicationFailed, patch.UnsupportedPatchFormat) as e: |
554 raise base.DiscardPending(pending, str(e)) | 561 raise base.DiscardPending(pending, str(e)) |
555 except subprocess2.CalledProcessError as e: | 562 except subprocess2.CalledProcessError as e: |
556 stdout = getattr(e, 'stdout', None) | 563 stdout = getattr(e, 'stdout', None) |
557 out = 'Failed to apply the patch.' | 564 out = 'Failed to apply the patch.' |
558 if stdout: | 565 if stdout: |
559 out += '\n%s' % stdout | 566 out += '\n%s' % stdout |
560 raise base.DiscardPending(pending, out) | 567 raise base.DiscardPending(pending, out) |
561 except base.DiscardPending as e: | 568 except base.DiscardPending as e: |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 """Loads the commit queue state from a JSON file.""" | 602 """Loads the commit queue state from a JSON file.""" |
596 self.queue = model.load_from_json_file(filename) | 603 self.queue = model.load_from_json_file(filename) |
597 | 604 |
598 def save(self, filename): | 605 def save(self, filename): |
599 """Save the commit queue state in a simple JSON file.""" | 606 """Save the commit queue state in a simple JSON file.""" |
600 model.save_to_json_file(filename, self.queue) | 607 model.save_to_json_file(filename, self.queue) |
601 | 608 |
602 def close(self): | 609 def close(self): |
603 """Close all the active pending manager items.""" | 610 """Close all the active pending manager items.""" |
604 self.context.status.close() | 611 self.context.status.close() |
OLD | NEW |