Title: [110948] trunk/Tools
Revision
110948
Author
[email protected]
Date
2012-03-15 23:18:37 -0700 (Thu, 15 Mar 2012)

Log Message

Move parse_bug_id into config/urls in preparation for re-use elsewhere.
https://bugs.webkit.org/show_bug.cgi?id=81313

Reviewed by Adam Barth.

* Scripts/webkitpy/common/checkout/changelog.py:
(parse_bug_id_from_changelog):
* Scripts/webkitpy/common/config/urls.py:
(parse_bug_id):
* Scripts/webkitpy/common/config/urls_unittest.py: Copied from Tools/Scripts/webkitpy/common/config/urls.py.
(URLsTest):
(URLsTest.test_parse_bug_id):
* Scripts/webkitpy/common/net/bugzilla/bugzilla_unittest.py:
(test_parse_bug_id):
* Scripts/webkitpy/tool/bot/irc_command.py:
(_post_error_and_check_for_bug_url):
* Scripts/webkitpy/tool/bot/sheriff.py:
(Sheriff.post_rollout_patch):
(Sheriff.post_chromium_deps_roll):

Modified Paths

Added Paths

Diff

Modified: trunk/Tools/ChangeLog (110947 => 110948)


--- trunk/Tools/ChangeLog	2012-03-16 06:09:18 UTC (rev 110947)
+++ trunk/Tools/ChangeLog	2012-03-16 06:18:37 UTC (rev 110948)
@@ -1,3 +1,25 @@
+2012-03-15  Eric Seidel  <[email protected]>
+
+        Move parse_bug_id into config/urls in preparation for re-use elsewhere.
+        https://bugs.webkit.org/show_bug.cgi?id=81313
+
+        Reviewed by Adam Barth.
+
+        * Scripts/webkitpy/common/checkout/changelog.py:
+        (parse_bug_id_from_changelog):
+        * Scripts/webkitpy/common/config/urls.py:
+        (parse_bug_id):
+        * Scripts/webkitpy/common/config/urls_unittest.py: Copied from Tools/Scripts/webkitpy/common/config/urls.py.
+        (URLsTest):
+        (URLsTest.test_parse_bug_id):
+        * Scripts/webkitpy/common/net/bugzilla/bugzilla_unittest.py:
+        (test_parse_bug_id):
+        * Scripts/webkitpy/tool/bot/irc_command.py:
+        (_post_error_and_check_for_bug_url):
+        * Scripts/webkitpy/tool/bot/sheriff.py:
+        (Sheriff.post_rollout_patch):
+        (Sheriff.post_chromium_deps_roll):
+
 2012-03-15  Adam Barth  <[email protected]>
 
         The commit-queue should fast-track patches that have already passed the testing EWS bots

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


--- trunk/Tools/Scripts/webkitpy/common/checkout/changelog.py	2012-03-16 06:09:18 UTC (rev 110947)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/changelog.py	2012-03-16 06:18:37 UTC (rev 110948)
@@ -39,20 +39,6 @@
 from webkitpy.common.system.deprecated_logging import log
 
 
-# FIXME: parse_bug_id should not be a free function.
-# FIXME: Where should this function live in the dependency graph?
-def parse_bug_id(message):
-    if not message:
-        return None
-    match = re.search(config_urls.bug_url_short, message)
-    if match:
-        return int(match.group('bug_id'))
-    match = re.search(config_urls.bug_url_long, message)
-    if match:
-        return int(match.group('bug_id'))
-    return None
-
-
 # FIXME: parse_bug_id_from_changelog should not be a free function.
 # Parse the bug ID out of a Changelog message based on the format that is
 # used by prepare-ChangeLog
@@ -67,7 +53,7 @@
         return int(match.group('bug_id'))
     # We weren't able to find a bug URL in the format used by prepare-ChangeLog. Fall back to the
     # first bug URL found anywhere in the message.
-    return parse_bug_id(message)
+    return config_urls.parse_bug_id(message)
 
 
 class ChangeLogEntry(object):

Modified: trunk/Tools/Scripts/webkitpy/common/config/urls.py (110947 => 110948)


--- trunk/Tools/Scripts/webkitpy/common/config/urls.py	2012-03-16 06:09:18 UTC (rev 110947)
+++ trunk/Tools/Scripts/webkitpy/common/config/urls.py	2012-03-16 06:18:37 UTC (rev 110948)
@@ -51,3 +51,15 @@
 
 buildbot_url = "http://build.webkit.org"
 chromium_buildbot_url = "http://build.chromium.org/p/chromium.webkit"
+
+
+def parse_bug_id(message):
+    if not message:
+        return None
+    match = re.search(bug_url_short, message)
+    if match:
+        return int(match.group('bug_id'))
+    match = re.search(bug_url_long, message)
+    if match:
+        return int(match.group('bug_id'))
+    return None

Copied: trunk/Tools/Scripts/webkitpy/common/config/urls_unittest.py (from rev 110947, trunk/Tools/Scripts/webkitpy/common/config/urls.py) (0 => 110948)


--- trunk/Tools/Scripts/webkitpy/common/config/urls_unittest.py	                        (rev 0)
+++ trunk/Tools/Scripts/webkitpy/common/config/urls_unittest.py	2012-03-16 06:18:37 UTC (rev 110948)
@@ -0,0 +1,43 @@
+# Copyright (C) 2012 Google 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:
+#
+#    * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#    * 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.
+#    * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+# OWNER OR 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.
+
+import unittest
+
+from .urls import parse_bug_id
+
+
+class URLsTest(unittest.TestCase):
+    def test_parse_bug_id(self):
+        # FIXME: These would be all better as doctests
+        self.assertEquals(12345, parse_bug_id("http://webkit.org/b/12345"))
+        self.assertEquals(12345, parse_bug_id("foo\n\nhttp://webkit.org/b/12345\nbar\n\n"))
+        self.assertEquals(12345, parse_bug_id("http://bugs.webkit.org/show_bug.cgi?id=12345"))
+
+        # Our url parser is super-fragile, but at least we're testing it.
+        self.assertEquals(None, parse_bug_id("http://www.webkit.org/b/12345"))
+        self.assertEquals(None, parse_bug_id("http://bugs.webkit.org/show_bug.cgi?ctype=xml&id=12345"))

Modified: trunk/Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla_unittest.py (110947 => 110948)


--- trunk/Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla_unittest.py	2012-03-16 06:09:18 UTC (rev 110947)
+++ trunk/Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla_unittest.py	2012-03-16 06:18:37 UTC (rev 110948)
@@ -32,7 +32,7 @@
 
 from .bugzilla import Bugzilla, BugzillaQueries, EditUsersParser
 
-from webkitpy.common.checkout.changelog import parse_bug_id
+from webkitpy.common.config import urls
 from webkitpy.common.system.outputcapture import OutputCapture
 from webkitpy.common.net.web_mock import MockBrowser
 from webkitpy.thirdparty.mock import Mock
@@ -89,18 +89,12 @@
         self.assertEquals(None, bugs.attachment_url_for_id(None))
 
     def test_parse_bug_id(self):
-        # FIXME: These would be all better as doctests
+        # Test that we can parse the urls we produce.
         bugs = Bugzilla()
-        self.assertEquals(12345, parse_bug_id("http://webkit.org/b/12345"))
-        self.assertEquals(12345, parse_bug_id("http://bugs.webkit.org/show_bug.cgi?id=12345"))
-        self.assertEquals(12345, parse_bug_id(bugs.short_bug_url_for_bug_id(12345)))
-        self.assertEquals(12345, parse_bug_id(bugs.bug_url_for_bug_id(12345)))
-        self.assertEquals(12345, parse_bug_id(bugs.bug_url_for_bug_id(12345, xml=True)))
+        self.assertEquals(12345, urls.parse_bug_id(bugs.short_bug_url_for_bug_id(12345)))
+        self.assertEquals(12345, urls.parse_bug_id(bugs.bug_url_for_bug_id(12345)))
+        self.assertEquals(12345, urls.parse_bug_id(bugs.bug_url_for_bug_id(12345, xml=True)))
 
-        # Our bug parser is super-fragile, but at least we're testing it.
-        self.assertEquals(None, parse_bug_id("http://www.webkit.org/b/12345"))
-        self.assertEquals(None, parse_bug_id("http://bugs.webkit.org/show_bug.cgi?ctype=xml&id=12345"))
-
     _bug_xml = """
     <bug>
           <bug_id>32585</bug_id>

Modified: trunk/Tools/Scripts/webkitpy/tool/bot/irc_command.py (110947 => 110948)


--- trunk/Tools/Scripts/webkitpy/tool/bot/irc_command.py	2012-03-16 06:09:18 UTC (rev 110947)
+++ trunk/Tools/Scripts/webkitpy/tool/bot/irc_command.py	2012-03-16 06:18:37 UTC (rev 110948)
@@ -33,7 +33,6 @@
 from webkitpy.common.config import irc as config_irc
 from webkitpy.common.config import urls
 from webkitpy.common.config.committers import CommitterList
-from webkitpy.common.checkout.changelog import parse_bug_id
 from webkitpy.common.system.executive import ScriptError
 from webkitpy.tool.bot.queueengine import TerminateQueue
 from webkitpy.tool.grammar import join_with_separators
@@ -41,7 +40,7 @@
 
 def _post_error_and_check_for_bug_url(tool, nicks_string, exception):
     tool.irc().post("%s" % exception)
-    bug_id = parse_bug_id(exception.output)
+    bug_id = urls.parse_bug_id(exception.output)
     if bug_id:
         bug_url = tool.bugs.bug_url_for_bug_id(bug_id)
         tool.irc().post("%s: Ugg...  Might have created %s" % (nicks_string, bug_url))

Modified: trunk/Tools/Scripts/webkitpy/tool/bot/sheriff.py (110947 => 110948)


--- trunk/Tools/Scripts/webkitpy/tool/bot/sheriff.py	2012-03-16 06:09:18 UTC (rev 110947)
+++ trunk/Tools/Scripts/webkitpy/tool/bot/sheriff.py	2012-03-16 06:18:37 UTC (rev 110948)
@@ -27,7 +27,6 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 from webkitpy.common.config import urls
-from webkitpy.common.checkout.changelog import parse_bug_id
 from webkitpy.common.system.deprecated_logging import log
 from webkitpy.common.system.executive import ScriptError
 from webkitpy.tool.grammar import join_with_separators
@@ -88,7 +87,7 @@
             svn_revisions,
             rollout_reason,
         ])
-        return parse_bug_id(output)
+        return urls.parse_bug_id(output)
 
     def post_chromium_deps_roll(self, revision, revision_name):
         args = [
@@ -100,7 +99,7 @@
         # revision can be None, but revision_name is always something meaningful.
         args += [revision, revision_name]
         output = self._sheriffbot.run_webkit_patch(args)
-        return parse_bug_id(output)
+        return urls.parse_bug_id(output)
 
     def post_blame_comment_on_bug(self, commit_info, builders, tests):
         if not commit_info.bug_id():
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to