Title: [234663] trunk/Tools
Revision
234663
Author
[email protected]
Date
2018-08-07 11:46:03 -0700 (Tue, 07 Aug 2018)

Log Message

If there's a Radar in the ChangeLog, webkit-patch upload/create-bug should put the radar in the bug and set InRadar
https://bugs.webkit.org/show_bug.cgi?id=188235

Reviewed by Daniel Bates, Kocsen Chung, and Aakash Jain.

* Scripts/webkitpy/common/checkout/changelog.py: 
(ChangeLogEntry): Teach the ChangeLog tools how to parse a radar_id
* Scripts/webkitpy/common/checkout/changelog_unittest.py: Test out the new _parse_radar_id functionality
* Scripts/webkitpy/common/net/bugzilla/bugzilla.py:
(Bugzilla.add_keyword_to_bug): Add logic to add keywords using the changeform
* Scripts/webkitpy/tool/commands/upload.py:
(Upload): Teach the upload step how to add radar information when creating a new bug.
* Scripts/webkitpy/tool/steps/__init__.py:
* Scripts/webkitpy/tool/steps/addradar.py: Added.
(AddRadar):
(AddRadar.run): Contains the logic to add the radar information to bugzilla.
* Scripts/webkitpy/tool/steps/createbug.py:
(CreateBug.run): set a "created_new_bug" state when creating a new bugzilla bug.

Modified Paths

Added Paths

Diff

Modified: trunk/Tools/ChangeLog (234662 => 234663)


--- trunk/Tools/ChangeLog	2018-08-07 18:33:25 UTC (rev 234662)
+++ trunk/Tools/ChangeLog	2018-08-07 18:46:03 UTC (rev 234663)
@@ -1,3 +1,24 @@
+2018-08-07  Lucas Forschler  <[email protected]>
+
+        If there's a Radar in the ChangeLog, webkit-patch upload/create-bug should put the radar in the bug and set InRadar
+        https://bugs.webkit.org/show_bug.cgi?id=188235
+
+        Reviewed by Daniel Bates, Kocsen Chung, and Aakash Jain.
+
+        * Scripts/webkitpy/common/checkout/changelog.py: 
+        (ChangeLogEntry): Teach the ChangeLog tools how to parse a radar_id
+        * Scripts/webkitpy/common/checkout/changelog_unittest.py: Test out the new _parse_radar_id functionality
+        * Scripts/webkitpy/common/net/bugzilla/bugzilla.py:
+        (Bugzilla.add_keyword_to_bug): Add logic to add keywords using the changeform
+        * Scripts/webkitpy/tool/commands/upload.py:
+        (Upload): Teach the upload step how to add radar information when creating a new bug.
+        * Scripts/webkitpy/tool/steps/__init__.py:
+        * Scripts/webkitpy/tool/steps/addradar.py: Added.
+        (AddRadar):
+        (AddRadar.run): Contains the logic to add the radar information to bugzilla.
+        * Scripts/webkitpy/tool/steps/createbug.py:
+        (CreateBug.run): set a "created_new_bug" state when creating a new bugzilla bug.
+
 2018-08-07  Wenson Hsieh  <[email protected]>
 
         Post-review feedback after r234614.

Modified: trunk/Tools/Scripts/webkitpy/common/checkout/changelog.py (234662 => 234663)


--- trunk/Tools/Scripts/webkitpy/common/checkout/changelog.py	2018-08-07 18:33:25 UTC (rev 234662)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/changelog.py	2018-08-07 18:46:03 UTC (rev 234663)
@@ -66,6 +66,8 @@
     # e.g. (ChangeLogEntry.touched_functions): Added.
     touched_functions_regexp = r'^\s*\((?P<function>[^)]*)\):'
 
+    radar_id_regexp = r'^\s*(<?rdar://problems?/)?(?P<radar_id>-?\d{7,})>?'
+
     # e.g. Reviewed by Darin Adler.
     # (Discard everything after the first period to match more invalid lines.)
     reviewed_by_regexp = r'^\s*((\w+\s+)+and\s+)?(Review|Rubber(\s*|-)stamp)(s|ed)?\s+([a-z]+\s+)*?by\s+(?P<reviewer>.*?)[\.,]?\s*$'
@@ -112,6 +114,19 @@
         self._parse_entry()
 
     @classmethod
+    def _parse_radar_id(cls, text):
+        if not text:
+            return None
+        match = re.search(ChangeLogEntry.radar_id_regexp, text, re.MULTILINE | re.IGNORECASE)
+        if not match:
+            return None
+        radar_id = int(match.group('radar_id'))
+        if radar_id < 0:
+            return None
+
+        return radar_id
+
+    @classmethod
     def _parse_reviewer_text(cls, text):
         match = re.search(ChangeLogEntry.reviewed_by_regexp, text, re.MULTILINE | re.IGNORECASE)
         if not match:

Modified: trunk/Tools/Scripts/webkitpy/common/checkout/changelog_unittest.py (234662 => 234663)


--- trunk/Tools/Scripts/webkitpy/common/checkout/changelog_unittest.py	2018-08-07 18:33:25 UTC (rev 234662)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/changelog_unittest.py	2018-08-07 18:46:03 UTC (rev 234663)
@@ -407,6 +407,116 @@
     def _contributors(self, names):
         return [CommitterList().contributor_by_name(name) for name in names]
 
+    def _assert_fuzzy_radar_match(self, radar_text, expected_radar_id):
+        parsed_radar_id = ChangeLogEntry._parse_radar_id(radar_text)
+        self.assertEqual(parsed_radar_id, expected_radar_id)
+
+    def test_fuzzy_radar_match__none(self):
+        self._assert_fuzzy_radar_match(None, None)
+        self._assert_fuzzy_radar_match('', None)
+
+        self._assert_fuzzy_radar_match('rdar://1', None)
+        self._assert_fuzzy_radar_match('rdar://12', None)
+        self._assert_fuzzy_radar_match('rdar://123', None)
+        self._assert_fuzzy_radar_match('rdar://1234', None)
+        self._assert_fuzzy_radar_match('rdar://12345', None)
+        self._assert_fuzzy_radar_match('rdar://123456', None)
+        self._assert_fuzzy_radar_match('rdar://1234567', None)
+        self._assert_fuzzy_radar_match('rdar://12345678', None)
+
+        self._assert_fuzzy_radar_match('<rdar://1>', None)
+        self._assert_fuzzy_radar_match('<rdar://12>', None)
+        self._assert_fuzzy_radar_match('<rdar://123>', None)
+        self._assert_fuzzy_radar_match('<rdar://1234>', None)
+        self._assert_fuzzy_radar_match('<rdar://12345>', None)
+        self._assert_fuzzy_radar_match('<rdar://123456>', None)
+        self._assert_fuzzy_radar_match('<rdar://1234567>', None)
+        self._assert_fuzzy_radar_match('<rdar://12345678>', None)
+
+        self._assert_fuzzy_radar_match('<rdar://problem/1>', None)
+        self._assert_fuzzy_radar_match('<rdar://problem/12>', None)
+        self._assert_fuzzy_radar_match('<rdar://problem/123>', None)
+        self._assert_fuzzy_radar_match('<rdar://problem/1234>', None)
+        self._assert_fuzzy_radar_match('<rdar://problem/12345>', None)
+        self._assert_fuzzy_radar_match('<rdar://problem/123456>', None)
+
+        self._assert_fuzzy_radar_match('<rdar://problems/1>', None)
+        self._assert_fuzzy_radar_match('<rdar://problems/12>', None)
+        self._assert_fuzzy_radar_match('<rdar://problems/123>', None)
+        self._assert_fuzzy_radar_match('<rdar://problems/1234>', None)
+        self._assert_fuzzy_radar_match('<rdar://problems/12345>', None)
+        self._assert_fuzzy_radar_match('<rdar://problems/123456>', None)
+
+        self._assert_fuzzy_radar_match('rdar://problem/1', None)
+        self._assert_fuzzy_radar_match('rdar://problem/12', None)
+        self._assert_fuzzy_radar_match('rdar://problem/123', None)
+        self._assert_fuzzy_radar_match('rdar://problem/1234', None)
+        self._assert_fuzzy_radar_match('rdar://problem/12345', None)
+        self._assert_fuzzy_radar_match('rdar://problem/123456', None)
+
+        self._assert_fuzzy_radar_match('rdar://problems/1', None)
+        self._assert_fuzzy_radar_match('rdar://problems/12', None)
+        self._assert_fuzzy_radar_match('rdar://problems/123', None)
+        self._assert_fuzzy_radar_match('rdar://problems/1234', None)
+        self._assert_fuzzy_radar_match('rdar://problems/12345', None)
+        self._assert_fuzzy_radar_match('rdar://problems/123456', None)
+
+        self._assert_fuzzy_radar_match('There is no rdar link here', None)
+        self._assert_fuzzy_radar_match('There is no rdar:// link here', None)
+        self._assert_fuzzy_radar_match('There is no malformed <rdar://abcd link here', None)
+        self._assert_fuzzy_radar_match('There is no malformed <rdar://problem> link here', None)
+        self._assert_fuzzy_radar_match('There is no malformed <rdar://problem/abcdefgh> link here', None)
+        self._assert_fuzzy_radar_match('There is no malformed <rdar://problem/1234> link here', None)
+        self._assert_fuzzy_radar_match('                fixed in <rdar://problem/2345678>', None)
+        self._assert_fuzzy_radar_match('                whitespace here <rdar://problem/12345678>', None)
+
+    def test_fuzzy_radar_match_format_1(self):
+        self._assert_fuzzy_radar_match('<rdar://problem/1234567>', 1234567)
+        self._assert_fuzzy_radar_match('<rdar://problem/12345678>', 12345678)
+
+        self._assert_fuzzy_radar_match('<rdar://problems/1234567>', 1234567)
+        self._assert_fuzzy_radar_match('<rdar://problems/12345678>', 12345678)
+
+    def test_fuzzy_radar_match_format_2(self):
+        self._assert_fuzzy_radar_match('rdar://problem/1234567', 1234567)
+        self._assert_fuzzy_radar_match('rdar://problem/12345678', 12345678)
+
+        self._assert_fuzzy_radar_match('rdar://problems/1234567', 1234567)
+        self._assert_fuzzy_radar_match('rdar://problems/12345678', 12345678)
+
+    def test_fuzzy_radar_match_format_3(self):
+        contents = """
+        2011-03-23  Ojan Vafai  <[email protected]>
+
+                Add failing result for WebKit2. All tests that require
+                focus fail on WebKit2. See https://bugs.webkit.org/show_bug.cgi?id=56988.
+                <rdar://problem/42824228>
+
+                * platform/mac-wk2/fast/css/pseudo-any-expected.txt: Added.
+
+               '''"""
+        self._assert_fuzzy_radar_match(contents, 42824228)
+
+        contents = """
+        2018-08-02  Wenson Hsieh  <[email protected]>
+
+                [iOS] Keyboard becomes unresponsive after pressing delete while pressing down on a character key with accents
+                https://bugs.webkit.org/show_bug.cgi?id=188251
+                <rdar://problem/37842108>
+        """
+        self._assert_fuzzy_radar_match(contents, 37842108)
+
+        contents = """
+        2017-06-26  Wenson Hsieh  <[email protected]>
+
+                Refactor drag start codepaths to plumb a DragItem to client layers
+                https://bugs.webkit.org/show_bug.cgi?id=173832
+                Work towards <rdar://problem/32236827>
+
+                Reviewed by Ryosuke Niwa and Tim Horton.
+        """
+        self._assert_fuzzy_radar_match(contents, None)
+
     def _assert_fuzzy_reviewer_match(self, reviewer_text, expected_text_list, expected_contributors):
         unused, reviewer_text_list = ChangeLogEntry._parse_reviewer_text(reviewer_text)
         self.assertEqual(reviewer_text_list, expected_text_list)

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


--- trunk/Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla.py	2018-08-07 18:33:25 UTC (rev 234662)
+++ trunk/Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla.py	2018-08-07 18:46:03 UTC (rev 234663)
@@ -851,6 +851,15 @@
         self.browser["newcc"] = ", ".join(email_address_list)
         self.browser.submit()
 
+    def add_keyword_to_bug(self, bug_id, keyword):
+        self.authenticate()
+
+        _log.info("Adding %s to the keyword list for bug %s" % (keyword, bug_id))
+        self.open_url(self.bug_url_for_bug_id(bug_id))
+        self.browser.select_form(name="changeform")
+        self.browser["keywords"] = keyword
+        self.browser.submit()
+
     def post_comment_to_bug(self, bug_id, comment_text, cc=None):
         self.authenticate()
 

Modified: trunk/Tools/Scripts/webkitpy/tool/commands/upload.py (234662 => 234663)


--- trunk/Tools/Scripts/webkitpy/tool/commands/upload.py	2018-08-07 18:33:25 UTC (rev 234662)
+++ trunk/Tools/Scripts/webkitpy/tool/commands/upload.py	2018-08-07 18:46:03 UTC (rev 234663)
@@ -285,6 +285,7 @@
         steps.SuggestReviewers,
         steps.EnsureBugIsOpenAndAssigned,
         steps.PostDiff,
+        steps.AddRadar,
         steps.SubmitToEWS,
         steps.WPTChangeExport,
     ]

Modified: trunk/Tools/Scripts/webkitpy/tool/steps/__init__.py (234662 => 234663)


--- trunk/Tools/Scripts/webkitpy/tool/steps/__init__.py	2018-08-07 18:33:25 UTC (rev 234662)
+++ trunk/Tools/Scripts/webkitpy/tool/steps/__init__.py	2018-08-07 18:46:03 UTC (rev 234663)
@@ -29,6 +29,7 @@
 
 # FIXME: Is this the right way to do this?
 from webkitpy.tool.steps.addsvnmimetypeforpng import AddSvnMimetypeForPng
+from webkitpy.tool.steps.addradar import AddRadar
 from webkitpy.tool.steps.applypatch import ApplyPatch
 from webkitpy.tool.steps.applypatchwithlocalcommit import ApplyPatchWithLocalCommit
 from webkitpy.tool.steps.applywatchlist import ApplyWatchList

Added: trunk/Tools/Scripts/webkitpy/tool/steps/addradar.py (0 => 234663)


--- trunk/Tools/Scripts/webkitpy/tool/steps/addradar.py	                        (rev 0)
+++ trunk/Tools/Scripts/webkitpy/tool/steps/addradar.py	2018-08-07 18:46:03 UTC (rev 234663)
@@ -0,0 +1,53 @@
+# Copyright (C) 2018 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1.  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+# 2.  Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+from webkitpy.tool.steps.abstractstep import AbstractStep
+from webkitpy.common.checkout.changelog import *
+
+import logging
+import re
+
+_log = logging.getLogger(__name__)
+
+
+class AddRadar(AbstractStep):
+    def run(self, state):
+        bug_id = state["bug_id"]
+        keyword = "InRadar"
+        wkbi_email = ["[email protected]"]
+        radar_link = None
+
+        # Only add Radar information if we are operating on a newly created bug
+        if not state.get("created_new_bug"):
+            return
+
+        for changelog_path in self.cached_lookup(state, "changelogs"):
+            changelog_entry = ChangeLog(changelog_path).latest_entry()
+            radar_id = ChangeLogEntry._parse_radar_id(changelog_entry.contents())
+            if radar_id:
+                radar_link = "<rdar://problem/{}>".format(radar_id)
+                break
+
+        if radar_link:
+            self._tool.bugs.add_keyword_to_bug(bug_id, keyword)
+            self._tool.bugs.post_comment_to_bug(bug_id, radar_link)
+            self._tool.bugs.add_cc_to_bug(bug_id, wkbi_email)

Modified: trunk/Tools/Scripts/webkitpy/tool/steps/createbug.py (234662 => 234663)


--- trunk/Tools/Scripts/webkitpy/tool/steps/createbug.py	2018-08-07 18:33:25 UTC (rev 234662)
+++ trunk/Tools/Scripts/webkitpy/tool/steps/createbug.py	2018-08-07 18:46:03 UTC (rev 234663)
@@ -52,6 +52,7 @@
             blocked_bugs = state.get("bug_id_list", [])
         blocks = ", ".join(str(bug) for bug in blocked_bugs if bug)
         state["bug_id"] = self._tool.bugs.create_bug(state["bug_title"], state["bug_description"], blocked=blocks, component=self._options.component, cc=cc)
+        state["created_new_bug"] = True
         for blocked_bug in blocked_bugs:
             if blocked_bug:
                 status = self._tool.bugs.fetch_bug(blocked_bug).status()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to