| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 | 72 |
| 73 It makes it possible to regenerate the try_jobs array if ever needed.""" | 73 It makes it possible to regenerate the try_jobs array if ever needed.""" |
| 74 return '%d-%d' % (self.issue, self.patchset) | 74 return '%d-%d' % (self.issue, self.patchset) |
| 75 | 75 |
| 76 def verify(self, revision, verifiers): | 76 def verify(self, revision, verifiers): |
| 77 """Runs verifiers on a pending change. | 77 """Runs verifiers on a pending change. |
| 78 | 78 |
| 79 Returns True if all Verifiers were run. | 79 Returns True if all Verifiers were run. |
| 80 """ | 80 """ |
| 81 for verifier in verifiers: | 81 for verifier in verifiers: |
| 82 assert verifier.name not in self.verifications | 82 if verifier.name in self.verifications: |
| 83 logging.warning( |
| 84 'Re-running verififer %s for issue %s' % ( |
| 85 verifier.name, self.issue)) |
| 83 verifier.verify(self, revision) | 86 verifier.verify(self, revision) |
| 84 assert verifier.name in self.verifications | 87 assert verifier.name in self.verifications |
| 85 if self.get_state() == base.IGNORED: | 88 if self.get_state() == base.IGNORED: |
| 86 assert self.verifications[verifier.name].get_state() == base.IGNORED | 89 assert self.verifications[verifier.name].get_state() == base.IGNORED |
| 87 # Remove all the other verifiers since we need to keep it in the | 90 # Remove all the other verifiers since we need to keep it in the |
| 88 # 'datastore' to not retry this issue constantly. | 91 # 'datastore' to not retry this issue constantly. |
| 89 for key in self.verifications.keys(): | 92 for key in self.verifications.keys(): |
| 90 if key != verifier.name: | 93 if key != verifier.name: |
| 91 del self.verifications[key] | 94 del self.verifications[key] |
| 92 return False | 95 return False |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 send_stack(e) | 157 send_stack(e) |
| 155 | 158 |
| 156 def _fetch_pending_issues(self): | 159 def _fetch_pending_issues(self): |
| 157 """Returns the list of issue number for reviews on Rietveld with their last | 160 """Returns the list of issue number for reviews on Rietveld with their last |
| 158 patchset with commit+ flag set. | 161 patchset with commit+ flag set. |
| 159 """ | 162 """ |
| 160 return self.rietveld.get_pending_issues() | 163 return self.rietveld.get_pending_issues() |
| 161 | 164 |
| 162 def process_new_pending_commit(self): | 165 def process_new_pending_commit(self): |
| 163 """Starts verification on newly found pending commits.""" | 166 """Starts verification on newly found pending commits.""" |
| 167 expected = set(i.name for i in self.all_verifiers) |
| 164 for pending in self.queue.pending_commits[:]: | 168 for pending in self.queue.pending_commits[:]: |
| 165 try: | 169 try: |
| 166 if (len(pending.verifications) == len(self.all_verifiers) or | 170 # Take in account the case where a verifier was removed. |
| 167 pending.get_state() != base.PROCESSING): | 171 done = set(pending.verifications.keys()) |
| 172 missing = expected - done |
| 173 if (not missing or pending.get_state() != base.PROCESSING): |
| 168 continue | 174 continue |
| 169 logging.info('Processing issue %s' % pending.issue) | 175 logging.info( |
| 176 'Processing issue %s (%s, %d)' % ( |
| 177 pending.issue, missing, pending.get_state())) |
| 170 | 178 |
| 171 revision = self.checkout.prepare() | 179 revision = self.checkout.prepare() |
| 172 if pending.verify(revision, self.pre_patch_verifiers): | 180 if pending.verify(revision, self.pre_patch_verifiers): |
| 173 self._apply_patch(pending, revision) | 181 self._apply_patch(pending, revision) |
| 174 previous_cwd = os.getcwd() | 182 previous_cwd = os.getcwd() |
| 175 try: | 183 try: |
| 176 os.chdir(self.checkout.project_path) | 184 os.chdir(self.checkout.project_path) |
| 177 pending.verify(revision, self.verifiers) | 185 pending.verify(revision, self.verifiers) |
| 178 finally: | 186 finally: |
| 179 os.chdir(previous_cwd) | 187 os.chdir(previous_cwd) |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 raise base.DiscardPending(pending, out) | 342 raise base.DiscardPending(pending, out) |
| 335 | 343 |
| 336 def load(self, filename): | 344 def load(self, filename): |
| 337 """Loads the commit queue state from a JSON file.""" | 345 """Loads the commit queue state from a JSON file.""" |
| 338 self.queue = model.load_from_json_file(filename) | 346 self.queue = model.load_from_json_file(filename) |
| 339 self.queue.pending_commits = self.queue.pending_commits or [] | 347 self.queue.pending_commits = self.queue.pending_commits or [] |
| 340 | 348 |
| 341 def save(self, filename): | 349 def save(self, filename): |
| 342 """Save the commit queue state in a simple JSON file.""" | 350 """Save the commit queue state in a simple JSON file.""" |
| 343 model.save_to_json_file(filename, self.queue) | 351 model.save_to_json_file(filename, self.queue) |
| OLD | NEW |