Changeset 52628 in webkit
- Timestamp:
- Dec 29, 2009 11:33:01 AM (14 years ago)
- Location:
- trunk/WebKitTools
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKitTools/ChangeLog
r52626 r52628 1 2009-12-29 Eric Seidel <eric@webkit.org> 2 3 Reviewed by Adam Barth. 4 5 Add the start of a Bug object for bugzilla.py 6 https://bugs.webkit.org/show_bug.cgi?id=32995 7 8 This allowed us to get rid of some duplicated "is_obsolete" checks. 9 10 * Scripts/modules/bugzilla.py: 11 - Add a new Bug class, and move patches/unreviewed_patches filtering logic there. 12 - Add _fetch_bug_page for possible future mocking. 13 (I did not try to test fetch_*_from_bug now due to difficulties with our current validate_reviewer logic.) 14 - Rename fetch_bug to fetch_bug_dictionary and add a new fetch_bug which returns a Bug object. 15 - Use fetch_bug and attachments(), patches(), etc. instead of custom fetch_*_from_bug methods. 16 - Reduce code in fetch_patches_from_pending_commit_list and fetch_patches_from_review_queue 17 using list comprehensions. Use a sum(list, []) trick to flatten a list of lists into a single list. 18 * Scripts/modules/bugzilla_unittest.py: 19 - Remove an unneeded unicode string marker. 20 * Scripts/modules/buildsteps.py: 21 - define __all__ to include just the BuildSteps 22 * Scripts/modules/commands/download.py: 23 - import * now that we have an __all__ defined. 24 * Scripts/modules/commands/upload.py: 25 - Use fetch_bug_dictionary instead of fetch_bug. 26 1 27 2009-12-29 Daniel Bates <dbates@webkit.org> 2 28 -
trunk/WebKitTools/Scripts/modules/bugzilla.py
r52595 r52628 64 64 65 65 66 # FIXME: This class is kinda a hack for now. It exists so we have one place 67 # to hold bug logic, even if much of the code deals with dictionaries still. 68 class Bug(object): 69 def __init__(self, bug_dictionary): 70 self.bug_dictionary = bug_dictionary 71 72 # Rarely do we actually want obsolete attachments 73 def attachments(self, include_obsolete=False): 74 if include_obsolete: 75 return self.bug_dictionary["attachments"][:] # Return a copy in either case. 76 return [attachment for attachment in self.bug_dictionary["attachments"] if not attachment["is_obsolete"]] 77 78 def patches(self, include_obsolete=False): 79 return [patch for patch in self.attachments(include_obsolete) if patch["is_patch"]] 80 81 def unreviewed_patches(self): 82 return [patch for patch in self.patches() if patch.get("review") == "?"] 83 84 66 85 class Bugzilla(object): 67 86 def __init__(self, dryrun=False, committers=CommitterList()): … … 69 88 self.authenticated = False 70 89 90 # FIXME: We should use some sort of Browser mock object when in dryrun mode (to prevent any mistakes). 71 91 self.browser = Browser() 72 92 # Ignore bugs.webkit.org/robots.txt until we fix it to allow this script … … 124 144 return bug 125 145 126 def fetch_bug(self, bug_id): 146 # Makes testing fetch_*_from_bug() possible until we have a better BugzillaNetwork abstration. 147 def _fetch_bug_page(self, bug_id): 127 148 bug_url = self.bug_url_for_bug_id(bug_id, xml=True) 128 149 log("Fetching: %s" % bug_url) 129 page = self.browser.open(bug_url) 130 return self._parse_bug_page(page) 131 132 # This should be an attachments() method on a Bug object. 133 def fetch_attachments_from_bug(self, bug_id): 134 bug = self.fetch_bug(bug_id) 135 if not bug: 136 return None 137 return bug["attachments"] 150 return self.browser.open(bug_url) 151 152 def fetch_bug_dictionary(self, bug_id): 153 return self._parse_bug_page(self._fetch_bug_page(bug_id)) 154 155 # FIXME: A BugzillaCache object should provide all these fetch_ methods. 156 def fetch_bug(self, bug_id): 157 return Bug(self.fetch_bug_dictionary(bug_id)) 138 158 139 159 def _parse_bug_id_from_attachment_page(self, page): … … 158 178 if not bug_id: 159 179 return None 160 attachments = self.fetch_attachments_from_bug(bug_id) 161 for attachment in attachments: 180 for attachment in self.fetch_bug(bug_id).attachments(include_obsolete=True): 162 181 # FIXME: Once we have a real Attachment class we shouldn't paper over this possible comparison failure 163 182 # and we should remove the int() == int() hacks and leave it just ==. … … 167 186 return None # This should never be hit. 168 187 188 # fetch_patches_from_bug exists until we expose a Bug class outside of bugzilla.py 169 189 def fetch_patches_from_bug(self, bug_id): 170 return [patch for patch in self.fetch_attachments_from_bug(bug_id) if patch['is_patch'] and not patch['is_obsolete']]190 return self.fetch_bug(bug_id).patches() 171 191 172 192 # _view_source_link belongs in some sort of webkit_config.py module. … … 216 236 self._validate_committer(patch, reject_invalid_patches=False) 217 237 218 def fetch_unreviewed_patches_from_bug(self, bug_id):219 return [patch for patch in self.fetch_attachments_from_bug(bug_id) if patch.get('review') == '?' and not patch['is_obsolete']]220 221 238 # FIXME: fetch_reviewed_patches_from_bug and fetch_commit_queue_patches_from_bug 222 239 # should share more code and use list comprehensions. 223 240 def fetch_reviewed_patches_from_bug(self, bug_id, reject_invalid_patches=False): 224 241 reviewed_patches = [] 225 for attachment in self.fetch_ attachments_from_bug(bug_id):226 if self._validate_reviewer(attachment, reject_invalid_patches) and not attachment['is_obsolete']:242 for attachment in self.fetch_bug(bug_id).attachments(): 243 if self._validate_reviewer(attachment, reject_invalid_patches): 227 244 reviewed_patches.append(attachment) 228 245 return reviewed_patches … … 231 248 commit_queue_patches = [] 232 249 for attachment in self.fetch_reviewed_patches_from_bug(bug_id, reject_invalid_patches): 233 if self._validate_committer(attachment, reject_invalid_patches) and not attachment['is_obsolete']:250 if self._validate_committer(attachment, reject_invalid_patches): 234 251 commit_queue_patches.append(attachment) 235 252 return commit_queue_patches … … 275 292 276 293 def fetch_patches_from_pending_commit_list(self): 277 patches_needing_commit = [] 278 for bug_id in self.fetch_bug_ids_from_needs_commit_list(): 279 patches = self.fetch_reviewed_patches_from_bug(bug_id) 280 patches_needing_commit += patches 281 return patches_needing_commit 294 return sum([self.fetch_reviewed_patches_from_bug(bug_id) for bug_id in self.fetch_bug_ids_from_needs_commit_list()], []) 282 295 283 296 def fetch_patches_from_review_queue(self, limit=None): 284 patches_to_review = [] 285 for bug_id in self.fetch_bug_ids_from_review_queue(): 286 if limit and len(patches_to_review) >= limit: 287 break 288 patches = self.fetch_unreviewed_patches_from_bug(bug_id) 289 patches_to_review += patches 290 return patches_to_review 297 return sum([self.fetch_bug(bug_id).unreviewed_patches() for bug_id in self.fetch_bug_ids_from_review_queue()[:limit]], []) # [:None] returns the whole array. 291 298 292 299 def authenticate(self): … … 445 452 self._set_flag_on_attachment(attachment_id, 'review', '-', comment_text, additional_comment_text) 446 453 454 # FIXME: All of these bug editing methods have a ridiculous amount of copy/paste code. 447 455 def obsolete_attachment(self, attachment_id, comment_text = None): 448 456 self.authenticate() -
trunk/WebKitTools/Scripts/modules/bugzilla_unittest.py
r52595 r52628 180 180 'url': 'https://bugs.webkit.org/attachment.cgi?id=45548', 181 181 'is_obsolete': False, 182 'review': u'?',182 'review': '?', 183 183 'is_patch': True, 184 184 'attacher_email': 'mjs@apple.com', -
trunk/WebKitTools/Scripts/modules/buildsteps.py
r52599 r52628 38 38 from modules.changelogs import ChangeLog 39 39 40 # FIXME: Why do some of these have "Step" in their name but not all? 41 __all__ = [ 42 "ApplyPatchStep", 43 "ApplyPatchWithLocalCommitStep", 44 "BuildStep", 45 "CheckStyleStep", 46 "CleanWorkingDirectoryStep", 47 "CleanWorkingDirectoryWithLocalCommitsStep", 48 "CloseBugForLandDiffStep", 49 "CloseBugStep", 50 "ClosePatchStep", 51 "CommitStep", 52 "CompleteRollout", 53 "CreateBugStep", 54 "EnsureBuildersAreGreenStep", 55 "EnsureLocalCommitIfNeeded", 56 "ObsoletePatchesOnBugStep", 57 "PostDiffToBugStep", 58 "PrepareChangeLogForRevertStep", 59 "PrepareChangeLogStep", 60 "PromptForBugOrTitleStep", 61 "RevertRevisionStep", 62 "RunTestsStep", 63 "UpdateChangeLogsWithReviewerStep", 64 "UpdateStep", 65 ] 40 66 41 67 class CommandOptions(object): -
trunk/WebKitTools/Scripts/modules/commands/download.py
r52528 r52628 34 34 35 35 from modules.bugzilla import parse_bug_id 36 # FIXME: This list is rediculous. We need to learn the ways of __all__.37 from modules.buildsteps import CommandOptions, EnsureBuildersAreGreenStep, EnsureLocalCommitIfNeeded, UpdateChangeLogsWithReviewerStep, CleanWorkingDirectoryStep, CleanWorkingDirectoryWithLocalCommitsStep, UpdateStep, ApplyPatchStep, ApplyPatchWithLocalCommitStep, BuildStep, CheckStyleStep, RunTestsStep, CommitStep, ClosePatchStep, CloseBugStep, CloseBugForLandDiffStep, PrepareChangeLogForRevertStep, RevertRevisionStep, CompleteRollout36 # We could instead use from modules import buildsteps and then prefix every buildstep with "buildsteps." 37 from modules.buildsteps import * 38 38 from modules.changelogs import ChangeLog 39 39 from modules.comments import bug_comment_from_commit_text -
trunk/WebKitTools/Scripts/modules/commands/upload.py
r52600 r52628 251 251 (bug_id, svn_revision) = self._determine_bug_id_and_svn_revision(tool, bug_id, svn_revision) 252 252 253 log("Bug: <%s> %s" % (tool.bugs.short_bug_url_for_bug_id(bug_id), tool.bugs.fetch_bug (bug_id)["title"]))253 log("Bug: <%s> %s" % (tool.bugs.short_bug_url_for_bug_id(bug_id), tool.bugs.fetch_bug_dictionary(bug_id)["title"])) 254 254 log("Revision: %s" % svn_revision) 255 255
Note: See TracChangeset
for help on using the changeset viewer.