Changeset 51959 in webkit
- Timestamp:
- Dec 10, 2009 1:17:00 PM (14 years ago)
- Location:
- trunk/WebKitTools
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKitTools/ChangeLog
r51956 r51959 1 2009-12-09 Eric Seidel <eric@webkit.org> 2 3 Reviewed by Adam Barth. 4 5 bugzilla-tool needs a command to list patches needing cq+ 6 https://bugs.webkit.org/show_bug.cgi?id=32351 7 8 * Scripts/modules/bugzilla.py: 9 - Parse attacher_email from attachment xml. 10 * Scripts/modules/bugzilla_unittest.py: 11 - Test new attacher_email parsing. 12 * Scripts/modules/commands/queries.py: 13 - Add PatchesToCommitQueue 14 * Scripts/modules/commands/queries_unittest.py: 15 - Tests for PatchesToCommitQueue 16 * Scripts/modules/mock_bugzillatool.py: 17 - Add necessary mock methods for running PatchesToCommitQueue 18 1 19 2009-12-10 Adam Barth <abarth@webkit.org> 2 20 -
trunk/WebKitTools/Scripts/modules/bugzilla.py
r51595 r51959 177 177 attachment['url'] = self.attachment_url_for_id(attachment['id']) 178 178 attachment['name'] = unicode(element.find('desc').string) 179 attachment['attacher_email'] = str(element.find('attacher').string) 179 180 attachment['type'] = str(element.find('type').string) 180 181 self._parse_attachment_flag(element, 'review', attachment, 'reviewer_email') … … 308 309 for bug_link_cell in soup('td', "first-child"): # tds with the class "first-child" 309 310 bug_link = bug_link_cell.find("a") 310 bug_ids.append( bug_link.string) # the contents happen to be the bug id311 bug_ids.append(int(bug_link.string)) # the contents happen to be the bug id 311 312 312 313 return bug_ids … … 324 325 commit_queue_url = self.bug_server_url + "buglist.cgi?query_format=advanced&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&field0-0-0=flagtypes.name&type0-0-0=equals&value0-0-0=commit-queue%2B" 325 326 return self._fetch_bug_ids_advanced_query(commit_queue_url) 327 328 # List of all r+'d bugs. 329 def fetch_bug_ids_from_needs_commit_list(self): 330 needs_commit_query_url = self.bug_server_url + "buglist.cgi?query_format=advanced&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&field0-0-0=flagtypes.name&type0-0-0=equals&value0-0-0=review%2B" 331 return self._fetch_bug_ids_advanced_query(needs_commit_query_url) 326 332 327 333 def fetch_bug_ids_from_review_queue(self): … … 339 345 patches_to_land += patches 340 346 return patches_to_land 347 348 def fetch_patches_from_pending_commit_list(self): 349 patches_needing_commit = [] 350 for bug_id in self.fetch_bug_ids_from_needs_commit_list(): 351 patches = self.fetch_reviewed_patches_from_bug(bug_id) 352 patches_needing_commit += patches 353 return patches_needing_commit 341 354 342 355 def fetch_patches_from_review_queue(self, limit=None): -
trunk/WebKitTools/Scripts/modules/bugzilla_unittest.py
r51595 r51959 73 73 'commit-queue' : '+', 74 74 'committer_email' : 'two@test.com', 75 'attacher_email' : 'christian.plesner.hansen@gmail.com', 75 76 } 76 77 -
trunk/WebKitTools/Scripts/modules/commands/queries.py
r51590 r51959 33 33 34 34 from modules.buildbot import BuildBot 35 from modules.committers import CommitterList 35 36 from modules.logging import log 36 37 from modules.multicommandtool import Command 38 37 39 38 40 class BugsToCommit(Command): … … 59 61 for patch in patches: 60 62 print "%s" % patch["url"] 63 64 65 class PatchesToCommitQueue(Command): 66 name = "patches-to-commit-queue" 67 show_in_main_help = False 68 def __init__(self): 69 options = [ 70 make_option("--bugs", action="store_true", dest="bugs", help="Output bug links instead of patch links"), 71 ] 72 Command.__init__(self, "Patches which should be added to the commit queue", options=options) 73 74 @staticmethod 75 def _needs_commit_queue(patch): 76 commit_queue_flag = patch.get("commit-queue") 77 if (commit_queue_flag and commit_queue_flag == '+'): # If it's already cq+, ignore the patch. 78 log("%s already has cq=%s" % (patch["id"], commit_queue_flag)) 79 return False 80 81 # We only need to worry about patches from contributers who are not yet committers. 82 committer_record = CommitterList().committer_by_email(patch["attacher_email"]) 83 if committer_record: 84 log("%s committer = %s" % (patch["id"], committer_record)) 85 return not committer_record 86 87 def execute(self, options, args, tool): 88 patches = tool.bugs.fetch_patches_from_pending_commit_list() 89 patches_needing_cq = filter(self._needs_commit_queue, patches) 90 if options.bugs: 91 bugs_needing_cq = map(lambda patch: patch['bug_id'], patches_needing_cq) 92 bugs_needing_cq = sorted(set(bugs_needing_cq)) 93 for bug_id in bugs_needing_cq: 94 print "%s" % tool.bugs.bug_url_for_bug_id(bug_id) 95 else: 96 for patch in patches_needing_cq: 97 print "%s" % tool.bugs.attachment_url_for_id(patch["id"], action="edit") 61 98 62 99 -
trunk/WebKitTools/Scripts/modules/commands/queries_unittest.py
r51464 r51959 29 29 import unittest 30 30 31 from modules.bugzilla import Bugzilla 31 32 from modules.commands.commandtest import CommandsTest 32 33 from modules.commands.queries import * 34 from modules.mock import Mock 35 from modules.mock_bugzillatool import MockBugzillaTool 33 36 34 37 class QueryCommandsTest(CommandsTest): … … 40 43 expected_stderr = "Patches in commit queue:\n" 41 44 self.assert_execute_outputs(PatchesToCommit(), None, expected_stdout, expected_stderr) 45 46 def test_patches_to_commit_queue(self): 47 expected_stdout = "http://example.com/197&action=edit\nhttp://example.com/128&action=edit\n" 48 expected_stderr = "" 49 options = Mock() 50 options.bugs = False 51 self.assert_execute_outputs(PatchesToCommitQueue(), None, expected_stdout, expected_stderr, options=options) 52 53 expected_stdout = "http://example.com/42\n" 54 options.bugs = True 55 self.assert_execute_outputs(PatchesToCommitQueue(), None, expected_stdout, expected_stderr, options=options) 42 56 43 57 def test_patches_to_review(self): -
trunk/WebKitTools/Scripts/modules/mock_bugzillatool.py
r51889 r51959 32 32 from modules.scm import CommitMessage 33 33 34 34 35 class MockBugzilla(Mock): 35 36 patch1 = { 36 "id": 197, 37 "bug_id": 42, 38 "url": "http://example.com/197", 39 "is_obsolete": False, 40 "reviewer": "Reviewer1" 37 "id" : 197, 38 "bug_id" : 42, 39 "url" : "http://example.com/197", 40 "is_obsolete" : False, 41 "reviewer" : "Reviewer1", 42 "attacher_email" : "Contributer1", 41 43 } 42 44 patch2 = { 43 "id": 128, 44 "bug_id": 42, 45 "url": "http://example.com/128", 46 "is_obsolete": False, 47 "reviewer": "Reviewer2" 45 "id" : 128, 46 "bug_id" : 42, 47 "url" : "http://example.com/128", 48 "is_obsolete" : False, 49 "reviewer" : "Reviewer2", 50 "attacher_email" : "Contributer2", 48 51 } 52 bug_server_url = "http://example.com" 49 53 50 54 def fetch_bug_ids_from_commit_queue(self): … … 55 59 56 60 def fetch_patches_from_commit_queue(self): 61 return [self.patch1, self.patch2] 62 63 def fetch_patches_from_pending_commit_list(self): 57 64 return [self.patch1, self.patch2] 58 65 … … 78 85 return self.patch2 79 86 raise Exception("Bogus attachment_id in fetch_attachment.") 87 88 def bug_url_for_bug_id(self, bug_id): 89 return "%s/%s" % (self.bug_server_url, bug_id) 90 91 def attachment_url_for_id(self, attachment_id, action): 92 action_param = "" 93 if action and action != "view": 94 action_param = "&action=%s" % action 95 return "%s/%s%s" % (self.bug_server_url, attachment_id, action_param) 80 96 81 97
Note: See TracChangeset
for help on using the changeset viewer.