Changeset 51959 in webkit


Ignore:
Timestamp:
Dec 10, 2009 1:17:00 PM (14 years ago)
Author:
eric@webkit.org
Message:

2009-12-09 Eric Seidel <eric@webkit.org>

Reviewed by Adam Barth.

bugzilla-tool needs a command to list patches needing cq+
https://bugs.webkit.org/show_bug.cgi?id=32351

  • Scripts/modules/bugzilla.py:
    • Parse attacher_email from attachment xml.
  • Scripts/modules/bugzilla_unittest.py:
    • Test new attacher_email parsing.
  • Scripts/modules/commands/queries.py:
    • Add PatchesToCommitQueue
  • Scripts/modules/commands/queries_unittest.py:
    • Tests for PatchesToCommitQueue
  • Scripts/modules/mock_bugzillatool.py:
    • Add necessary mock methods for running PatchesToCommitQueue
Location:
trunk/WebKitTools
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r51956 r51959  
     12009-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
    1192009-12-10  Adam Barth  <abarth@webkit.org>
    220
  • trunk/WebKitTools/Scripts/modules/bugzilla.py

    r51595 r51959  
    177177        attachment['url'] = self.attachment_url_for_id(attachment['id'])
    178178        attachment['name'] = unicode(element.find('desc').string)
     179        attachment['attacher_email'] = str(element.find('attacher').string)
    179180        attachment['type'] = str(element.find('type').string)
    180181        self._parse_attachment_flag(element, 'review', attachment, 'reviewer_email')
     
    308309        for bug_link_cell in soup('td', "first-child"): # tds with the class "first-child"
    309310            bug_link = bug_link_cell.find("a")
    310             bug_ids.append(bug_link.string) # the contents happen to be the bug id
     311            bug_ids.append(int(bug_link.string)) # the contents happen to be the bug id
    311312
    312313        return bug_ids
     
    324325        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"
    325326        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)
    326332
    327333    def fetch_bug_ids_from_review_queue(self):
     
    339345            patches_to_land += patches
    340346        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
    341354
    342355    def fetch_patches_from_review_queue(self, limit=None):
  • trunk/WebKitTools/Scripts/modules/bugzilla_unittest.py

    r51595 r51959  
    7373        'commit-queue' : '+',
    7474        'committer_email' : 'two@test.com',
     75        'attacher_email' : 'christian.plesner.hansen@gmail.com',
    7576    }
    7677
  • trunk/WebKitTools/Scripts/modules/commands/queries.py

    r51590 r51959  
    3333
    3434from modules.buildbot import BuildBot
     35from modules.committers import CommitterList
    3536from modules.logging import log
    3637from modules.multicommandtool import Command
     38
    3739
    3840class BugsToCommit(Command):
     
    5961        for patch in patches:
    6062            print "%s" % patch["url"]
     63
     64
     65class 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")
    6198
    6299
  • trunk/WebKitTools/Scripts/modules/commands/queries_unittest.py

    r51464 r51959  
    2929import unittest
    3030
     31from modules.bugzilla import Bugzilla
    3132from modules.commands.commandtest import CommandsTest
    3233from modules.commands.queries import *
     34from modules.mock import Mock
     35from modules.mock_bugzillatool import MockBugzillaTool
    3336
    3437class QueryCommandsTest(CommandsTest):
     
    4043        expected_stderr = "Patches in commit queue:\n"
    4144        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)
    4256
    4357    def test_patches_to_review(self):
  • trunk/WebKitTools/Scripts/modules/mock_bugzillatool.py

    r51889 r51959  
    3232from modules.scm import CommitMessage
    3333
     34
    3435class MockBugzilla(Mock):
    3536    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",
    4143    }
    4244    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",
    4851    }
     52    bug_server_url = "http://example.com"
    4953
    5054    def fetch_bug_ids_from_commit_queue(self):
     
    5559
    5660    def fetch_patches_from_commit_queue(self):
     61        return [self.patch1, self.patch2]
     62
     63    def fetch_patches_from_pending_commit_list(self):
    5764        return [self.patch1, self.patch2]
    5865
     
    7885            return self.patch2
    7986        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)
    8096
    8197
Note: See TracChangeset for help on using the changeset viewer.