Title: [121269] trunk/Tools
Revision
121269
Author
commit-qu...@webkit.org
Date
2012-06-26 11:27:44 -0700 (Tue, 26 Jun 2012)

Log Message

webkitpy: Make webkit-patch patches-to-review useful
https://bugs.webkit.org/show_bug.cgi?id=89470

Patch by Thiago Marcos P. Santos <thiago.san...@intel.com> on 2012-06-26
Reviewed by Eric Seidel.

webkit-patch patches-to-review will now output the list of
bugs with patches pending for review that has the user on CC,
excluding patches with cq-, sorted by the age of the patch.

* Scripts/webkitpy/common/net/bugzilla/bugzilla.py:
(BugzillaQueries.fetch_bugs_from_review_queue):
* Scripts/webkitpy/common/net/bugzilla/bugzilla_mock.py:
(MockBugzillaQueries.fetch_bugs_from_review_queue):
(MockBugzilla.__init__):
(MockBugzilla.authenticate):
* Scripts/webkitpy/tool/commands/queries.py:
(PatchesToReview):
(PatchesToReview.__init__):
(PatchesToReview._print_report):
(PatchesToReview._generate_report):
(PatchesToReview.execute):
* Scripts/webkitpy/tool/commands/queries_unittest.py:
(QueryCommandsTest.test_patches_to_review):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (121268 => 121269)


--- trunk/Tools/ChangeLog	2012-06-26 18:09:22 UTC (rev 121268)
+++ trunk/Tools/ChangeLog	2012-06-26 18:27:44 UTC (rev 121269)
@@ -1,3 +1,29 @@
+2012-06-26  Thiago Marcos P. Santos  <thiago.san...@intel.com>
+
+        webkitpy: Make webkit-patch patches-to-review useful
+        https://bugs.webkit.org/show_bug.cgi?id=89470
+
+        Reviewed by Eric Seidel.
+
+        webkit-patch patches-to-review will now output the list of
+        bugs with patches pending for review that has the user on CC,
+        excluding patches with cq-, sorted by the age of the patch.
+
+        * Scripts/webkitpy/common/net/bugzilla/bugzilla.py:
+        (BugzillaQueries.fetch_bugs_from_review_queue):
+        * Scripts/webkitpy/common/net/bugzilla/bugzilla_mock.py:
+        (MockBugzillaQueries.fetch_bugs_from_review_queue):
+        (MockBugzilla.__init__):
+        (MockBugzilla.authenticate):
+        * Scripts/webkitpy/tool/commands/queries.py:
+        (PatchesToReview):
+        (PatchesToReview.__init__):
+        (PatchesToReview._print_report):
+        (PatchesToReview._generate_report):
+        (PatchesToReview.execute):
+        * Scripts/webkitpy/tool/commands/queries_unittest.py:
+        (QueryCommandsTest.test_patches_to_review):
+
 2012-06-26  Dirk Pranke  <dpra...@chromium.org>
 
         nrwt: broken for chromium on vista

Modified: trunk/Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla.py (121268 => 121269)


--- trunk/Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla.py	2012-06-26 18:09:22 UTC (rev 121268)
+++ trunk/Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla.py	2012-06-26 18:27:44 UTC (rev 121269)
@@ -219,6 +219,14 @@
         return sum([self._fetch_bug(bug_id).reviewed_patches()
             for bug_id in self.fetch_bug_ids_from_pending_commit_list()], [])
 
+    def fetch_bugs_from_review_queue(self, cc_email=None):
+        query = "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?"
+
+        if cc_email:
+            query += "&emailcc1=1&emailtype1=substring&email1=%s" % urllib.quote(cc_email)
+
+        return self._fetch_bugs_from_advanced_query(query)
+
     def fetch_bug_ids_from_commit_queue(self):
         commit_queue_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&order=Last+Changed"
         return self._fetch_bug_ids_advanced_query(commit_queue_url)

Modified: trunk/Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla_mock.py (121268 => 121269)


--- trunk/Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla_mock.py	2012-06-26 18:09:22 UTC (rev 121268)
+++ trunk/Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla_mock.py	2012-06-26 18:27:44 UTC (rev 121269)
@@ -82,7 +82,9 @@
     "is_obsolete": False,
     "is_patch": True,
     "review": "?",
+    "commit-queue": "-",
     "attacher_email": "e...@webkit.org",
+    "attach_date": datetime.datetime.today(),
 }
 
 
@@ -266,6 +268,14 @@
         # will return bugs with patches which have r+, but are also obsolete.
         return bug_ids + [50002]
 
+    def fetch_bugs_from_review_queue(self, cc_email=None):
+        unreviewed_bugs = [bug for bug in self._all_bugs() if bug.unreviewed_patches()]
+
+        if cc_email:
+            return [bug for bug in unreviewed_bugs if cc_email in bug.cc_emails()]
+
+        return unreviewed_bugs
+
     def fetch_patches_from_pending_commit_list(self):
         return sum([bug.reviewed_patches() for bug in self._all_bugs()], [])
 
@@ -302,8 +312,12 @@
         self.queries = MockBugzillaQueries(self)
         # FIXME: This should move onto the Host object, and we should use a MockCommitterList
         self.committers = CommitterList(reviewers=_mock_reviewers)
+        self.username = None
         self._override_patch = None
 
+    def authenticate(self):
+        self.username = "usern...@webkit.org"
+
     def create_bug(self,
                    bug_title,
                    bug_description,

Modified: trunk/Tools/Scripts/webkitpy/tool/commands/queries.py (121268 => 121269)


--- trunk/Tools/Scripts/webkitpy/tool/commands/queries.py	2012-06-26 18:09:22 UTC (rev 121268)
+++ trunk/Tools/Scripts/webkitpy/tool/commands/queries.py	2012-06-26 18:27:44 UTC (rev 121269)
@@ -1,5 +1,6 @@
 # Copyright (c) 2009 Google Inc. All rights reserved.
 # Copyright (c) 2009 Apple Inc. All rights reserved.
+# Copyright (c) 2012 Intel Corporation. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions are
@@ -30,6 +31,7 @@
 import fnmatch
 import re
 
+from datetime import datetime
 from optparse import make_option
 
 from webkitpy.tool import steps
@@ -121,15 +123,57 @@
 
 class PatchesToReview(AbstractDeclarativeCommand):
     name = "patches-to-review"
-    help_text = "List patches that are pending review"
+    help_text = "List bugs which have attachments pending review"
 
+    def __init__(self):
+        options = [
+            make_option("--all", action=""
+                        help="Show all bugs regardless of who is on CC (it might take a while)"),
+            make_option("--include-cq-denied", action=""
+                        help="By default, r? patches with cq- are omitted unless this option is set"),
+            make_option("--cc-email",
+                        help="Specifies the email on the CC field (defaults to your bugzilla login email)"),
+        ]
+        AbstractDeclarativeCommand.__init__(self, options=options)
+
+    def _print_report(self, report, cc_email, print_all):
+        if print_all:
+            print "Bugs with attachments pending review:"
+        else:
+            print "Bugs with attachments pending review that has %s in the CC list:" % cc_email
+
+        print "http://webkit.org/b/bugid   Description (age in days)"
+        for row in report:
+            print "%s (%d)" % (row[1], row[0])
+
+        print "Total: %d" % len(report)
+
+    def _generate_report(self, bugs, include_cq_denied):
+        report = []
+
+        for bug in bugs:
+            patch = bug.unreviewed_patches()[-1]
+
+            if not include_cq_denied and patch.commit_queue() == "-":
+                continue
+
+            age_in_days = (datetime.today() - patch.attach_date()).days
+            report.append((age_in_days, "http://webkit.org/b/%-7s %s" % (bug.id(), bug.title())))
+
+        report.sort()
+        return report
+
     def execute(self, options, args, tool):
-        patch_ids = tool.bugs.queries.fetch_attachment_ids_from_review_queue()
-        log("Patches pending review:")
-        for patch_id in patch_ids:
-            print patch_id
+        tool.bugs.authenticate()
 
+        cc_email = options.cc_email
+        if not cc_email and not options.all:
+            cc_email = tool.bugs.username
 
+        bugs = tool.bugs.queries.fetch_bugs_from_review_queue(cc_email=cc_email)
+        report = self._generate_report(bugs, options.include_cq_denied)
+        self._print_report(report, cc_email, options.all)
+
 class WhatBroke(AbstractDeclarativeCommand):
     name = "what-broke"
     help_text = "Print failing buildbots (%s) and what revisions broke them" % config_urls.buildbot_url

Modified: trunk/Tools/Scripts/webkitpy/tool/commands/queries_unittest.py (121268 => 121269)


--- trunk/Tools/Scripts/webkitpy/tool/commands/queries_unittest.py	2012-06-26 18:09:22 UTC (rev 121268)
+++ trunk/Tools/Scripts/webkitpy/tool/commands/queries_unittest.py	2012-06-26 18:27:44 UTC (rev 121269)
@@ -1,4 +1,5 @@
 # Copyright (C) 2009 Google Inc. All rights reserved.
+# Copyright (C) 2012 Intel Corporation. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions are
@@ -84,10 +85,60 @@
         self.assert_execute_outputs(PatchesToCommitQueue(), None, expected_stdout, expected_stderr, options=options)
 
     def test_patches_to_review(self):
-        expected_stdout = "10002\n"
-        expected_stderr = "Patches pending review:\n"
-        self.assert_execute_outputs(PatchesToReview(), None, expected_stdout, expected_stderr)
+        options = Mock()
 
+        # When no cc_email is provided, we use the Bugzilla username by default.
+        # The MockBugzilla will fake the authentication using usern...@webkit.org
+        # as login and it should match the username at the report header.
+        options.cc_email = None
+        options.include_cq_denied = False
+        options.all = False
+        expected_stdout = \
+            "Bugs with attachments pending review that has usern...@webkit.org in the CC list:\n" \
+            "http://webkit.org/b/bugid   Description (age in days)\n" \
+            "Total: 0\n"
+        expected_stderr = ""
+        self.assert_execute_outputs(PatchesToReview(), None, expected_stdout, expected_stderr, options=options)
+
+        options.cc_email = "aba...@webkit.org"
+        options.include_cq_denied = True
+        options.all = False
+        expected_stdout = \
+            "Bugs with attachments pending review that has aba...@webkit.org in the CC list:\n" \
+            "http://webkit.org/b/bugid   Description (age in days)\n" \
+            "http://webkit.org/b/50001   Bug with a patch needing review. (0)\n" \
+            "Total: 1\n"
+        expected_stderr = ""
+        self.assert_execute_outputs(PatchesToReview(), None, expected_stdout, expected_stderr, options=options)
+
+        options.cc_email = None
+        options.include_cq_denied = True
+        options.all = True
+        expected_stdout = \
+            "Bugs with attachments pending review:\n" \
+            "http://webkit.org/b/bugid   Description (age in days)\n" \
+            "http://webkit.org/b/50001   Bug with a patch needing review. (0)\n" \
+            "Total: 1\n"
+        self.assert_execute_outputs(PatchesToReview(), None, expected_stdout, expected_stderr, options=options)
+
+        options.cc_email = None
+        options.include_cq_denied = False
+        options.all = True
+        expected_stdout = \
+            "Bugs with attachments pending review:\n" \
+            "http://webkit.org/b/bugid   Description (age in days)\n" \
+            "Total: 0\n"
+        self.assert_execute_outputs(PatchesToReview(), None, expected_stdout, expected_stderr, options=options)
+
+        options.cc_email = "invalid_em...@example.com"
+        options.all = False
+        options.include_cq_denied = True
+        expected_stdout = \
+            "Bugs with attachments pending review that has invalid_em...@example.com in the CC list:\n" \
+            "http://webkit.org/b/bugid   Description (age in days)\n" \
+            "Total: 0\n"
+        self.assert_execute_outputs(PatchesToReview(), None, expected_stdout, expected_stderr, options=options)
+
     def test_tree_status(self):
         expected_stdout = "ok   : Builder1\nok   : Builder2\n"
         self.assert_execute_outputs(TreeStatus(), None, expected_stdout)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to