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

Side by Side Diff: pending_manager.py

Issue 11414143: Change models.py to use typed class members instead of a list of strings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/commit-queue
Patch Set: Address review comments Created 8 years, 1 month 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 | « model.py ('k') | tests/model_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 13 matching lines...) Expand all
24 import patch 24 import patch
25 import subprocess2 25 import subprocess2
26 26
27 import errors 27 import errors
28 import model 28 import model
29 from verification import base 29 from verification import base
30 30
31 31
32 class PendingCommit(base.Verified): 32 class PendingCommit(base.Verified):
33 """Represents a pending commit that is being processed.""" 33 """Represents a pending commit that is being processed."""
34 persistent = base.Verified.persistent + [ 34 # Important since they tell if we need to revalidate and send try jobs
35 # Important since they tell if we need to revalidate and send try jobs 35 # again or not if any of these value changes.
36 # again or not if any of these value changes. 36 issue = int
37 'issue', 'patchset', 'description', 'files', 37 patchset = int
38 # Only a cache, these values can be regenerated. 38 description = unicode
39 'owner', 'reviewers', 'base_url', 'messages', 'relpath', 39 files = list
40 # Only used after a patch was committed. Keeping here for try job retries. 40 # Only a cache, these values can be regenerated.
41 'revision', 41 owner = str
42 ] 42 reviewers = list
43 base_url = str
44 messages = list
45 relpath = str
46 # Only used after a patch was committed. Keeping here for try job retries.
47 revision = (None, int, str)
43 48
44 def __init__( 49 def __init__(self, description, **kwargs):
45 self, issue, owner, reviewers, patchset, base_url, description, 50 # Convert description to unicode whenever necessary.
46 messages): 51 if isinstance(description, str):
47 super(PendingCommit, self).__init__() 52 description = description.decode('utf-8')
48 self.issue = issue 53 super(PendingCommit, self).__init__(description=description, **kwargs)
49 self.owner = owner
50 self.reviewers = reviewers
51 self.patchset = patchset
52 self.base_url = base_url
53 self.description = description
54 # Convert to unicode whenever necessary.
55 if isinstance(self.description, str):
56 self.description = self.description.decode('utf-8')
57 assert isinstance(self.description, unicode)
58 self.messages = messages
59 for message in self.messages: 54 for message in self.messages:
60 # Save storage, no verifier really need 'text', just 'approval'. 55 # Save storage, no verifier really need 'text', just 'approval'.
61 if 'text' in message: 56 if 'text' in message:
62 del message['text'] 57 del message['text']
63 self.revision = None
64 self.relpath = ''
65 self.files = []
66 58
67 def pending_name(self): 59 def pending_name(self):
68 """The name that should be used for try jobs. 60 """The name that should be used for try jobs.
69 61
70 It makes it possible to regenerate the try_jobs array if ever needed.""" 62 It makes it possible to regenerate the try_jobs array if ever needed."""
71 return '%d-%d' % (self.issue, self.patchset) 63 return '%d-%d' % (self.issue, self.patchset)
72 64
73 def prepare_for_patch(self, context_obj): 65 def prepare_for_patch(self, context_obj):
74 self.revision = context_obj.checkout.prepare(self.revision) 66 self.revision = context_obj.checkout.prepare(self.revision)
75 # Verify revision consistency. 67 # Verify revision consistency.
(...skipping 27 matching lines...) Expand all
103 except urllib2.HTTPError, e: 95 except urllib2.HTTPError, e:
104 raise base.DiscardPending( 96 raise base.DiscardPending(
105 self, 97 self,
106 ('Failed to request the patch to try. Please note that binary files' 98 ('Failed to request the patch to try. Please note that binary files'
107 'are still unsupported at the moment, this is being worked on.\n\n' 99 'are still unsupported at the moment, this is being worked on.\n\n'
108 'Thanks for your patience.\n\n%s') % e) 100 'Thanks for your patience.\n\n%s') % e)
109 101
110 102
111 class PendingQueue(model.PersistentMixIn): 103 class PendingQueue(model.PersistentMixIn):
112 """Represents the queue of pending commits being processed.""" 104 """Represents the queue of pending commits being processed."""
113 persistent = ['pending_commits'] 105 pending_commits = list
114
115 def __init__(self):
116 super(PendingQueue, self).__init__()
117 self.pending_commits = []
118 106
119 107
120 class PendingManager(object): 108 class PendingManager(object):
121 """Fetch new issues from rietveld, pass the issues through all of verifiers 109 """Fetch new issues from rietveld, pass the issues through all of verifiers
122 and then commit the patches with checkout. 110 and then commit the patches with checkout.
123 """ 111 """
124 FAILED_NO_MESSAGE = ( 112 FAILED_NO_MESSAGE = (
125 'Commit queue patch verification failed without an error message.\n' 113 'Commit queue patch verification failed without an error message.\n'
126 'Something went wrong, probably a crash, a hickup or simply\n' 114 'Something went wrong, probably a crash, a hickup or simply\n'
127 'the monkeys went out for dinner.\n' 115 'the monkeys went out for dinner.\n'
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 455
468 def load(self, filename): 456 def load(self, filename):
469 """Loads the commit queue state from a JSON file.""" 457 """Loads the commit queue state from a JSON file."""
470 self.queue = model.load_from_json_file(filename) 458 self.queue = model.load_from_json_file(filename)
471 self.queue.pending_commits = self.queue.pending_commits or [] 459 self.queue.pending_commits = self.queue.pending_commits or []
472 460
473 def save(self, filename): 461 def save(self, filename):
474 """Save the commit queue state in a simple JSON file.""" 462 """Save the commit queue state in a simple JSON file."""
475 model.save_to_json_file(filename, self.queue) 463 model.save_to_json_file(filename, self.queue)
476 self.context.status.close() 464 self.context.status.close()
OLDNEW
« no previous file with comments | « model.py ('k') | tests/model_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698