Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

Side by Side Diff: pending_manager.py

Issue 102703004: Improved user-facing messages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/commit-queue
Patch Set: Fixed quotes Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « async_push.py ('k') | tests/pending_manager_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 DESCRIPTION_UPDATED = ( 141 DESCRIPTION_UPDATED = (
142 'Commit queue rejected this change because the description was changed\n' 142 'Commit queue rejected this change because the description was changed\n'
143 'between the time the change entered the commit queue and the time it\n' 143 'between the time the change entered the commit queue and the time it\n'
144 'was ready to commit. You can safely check the commit box again.') 144 'was ready to commit. You can safely check the commit box again.')
145 TRYING_PATCH = 'CQ is trying da patch. Follow status at\n' 145 TRYING_PATCH = 'CQ is trying da patch. Follow status at\n'
146 # Maximum number of commits done in a burst. 146 # Maximum number of commits done in a burst.
147 MAX_COMMIT_BURST = 4 147 MAX_COMMIT_BURST = 4
148 # Delay (secs) between commit bursts. 148 # Delay (secs) between commit bursts.
149 COMMIT_BURST_DELAY = 10*60 149 COMMIT_BURST_DELAY = 10*60
150 150
151 def __init__(self, context_obj, pre_patch_verifiers, verifiers): 151 def __init__(self, context_obj, pre_patch_verifiers, verifiers,
152 project_name=''):
152 """ 153 """
153 Args: 154 Args:
154 pre_patch_verifiers: Verifiers objects that are run before applying the 155 pre_patch_verifiers: Verifiers objects that are run before applying the
155 patch. 156 patch.
156 verifiers: Verifiers object run after applying the patch. 157 verifiers: Verifiers object run after applying the patch.
157 """ 158 """
158 assert len(pre_patch_verifiers) or len(verifiers) 159 if not(len(pre_patch_verifiers) or len(verifiers)):
160 raise ValueError('at least one verifier should be defined (in project %s)'
161 % project_name)
162
159 self.context = context_obj 163 self.context = context_obj
160 self.pre_patch_verifiers = pre_patch_verifiers or [] 164 self.pre_patch_verifiers = pre_patch_verifiers or []
161 self.verifiers = verifiers or [] 165 self.verifiers = verifiers or []
162 self.all_verifiers = pre_patch_verifiers + verifiers 166 self.all_verifiers = pre_patch_verifiers + verifiers
163 self.queue = PendingQueue() 167 self.queue = PendingQueue()
164 # Keep the timestamps of the last few commits so that we can control the 168 # Keep the timestamps of the last few commits so that we can control the
165 # pace (burstiness) of commits. 169 # pace (burstiness) of commits.
166 self.recent_commit_timestamps = [] 170 self.recent_commit_timestamps = []
167 # Assert names are unique. 171 # Assert names are unique.
168 names = [x.name for x in pre_patch_verifiers + verifiers] 172 names = [x.name for x in pre_patch_verifiers + verifiers]
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 try: 426 try:
423 try: 427 try:
424 if pending.get_state() != base.IGNORED: 428 if pending.get_state() != base.IGNORED:
425 self.context.rietveld.set_flag( 429 self.context.rietveld.set_flag(
426 pending.issue, pending.patchset, 'commit', False) 430 pending.issue, pending.patchset, 'commit', False)
427 except urllib2.HTTPError as e: 431 except urllib2.HTTPError as e:
428 logging.error( 432 logging.error(
429 'Failed to set the flag to False for %s with message %s' % ( 433 'Failed to set the flag to False for %s with message %s' % (
430 pending.pending_name(), message)) 434 pending.pending_name(), message))
431 traceback.print_stack() 435 traceback.print_stack()
436 logging.error(str(e))
432 errors.send_stack(e) 437 errors.send_stack(e)
433 if message: 438 if message:
434 try: 439 try:
435 self.context.rietveld.add_comment(pending.issue, message) 440 self.context.rietveld.add_comment(pending.issue, message)
436 except urllib2.HTTPError as e: 441 except urllib2.HTTPError as e:
437 logging.error( 442 logging.error(
438 'Failed to add comment for %s with message %s' % ( 443 'Failed to add comment for %s with message %s' % (
439 pending.pending_name(), message)) 444 pending.pending_name(), message))
440 traceback.print_stack() 445 traceback.print_stack()
441 errors.send_stack(e) 446 errors.send_stack(e)
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 """Loads the commit queue state from a JSON file.""" 560 """Loads the commit queue state from a JSON file."""
556 self.queue = model.load_from_json_file(filename) 561 self.queue = model.load_from_json_file(filename)
557 562
558 def save(self, filename): 563 def save(self, filename):
559 """Save the commit queue state in a simple JSON file.""" 564 """Save the commit queue state in a simple JSON file."""
560 model.save_to_json_file(filename, self.queue) 565 model.save_to_json_file(filename, self.queue)
561 566
562 def close(self): 567 def close(self):
563 """Close all the active pending manager items.""" 568 """Close all the active pending manager items."""
564 self.context.status.close() 569 self.context.status.close()
OLDNEW
« no previous file with comments | « async_push.py ('k') | tests/pending_manager_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698