Changeset 85727 in webkit


Ignore:
Timestamp:
May 4, 2011 3:44:18 AM (13 years ago)
Author:
abarth@webkit.org
Message:

2011-05-04 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.

Fix circular dependency in webkitpy
https://bugs.webkit.org/show_bug.cgi?id=60075

These functions don't belong in bugzilla.py. They only exist there
because they are old. Really, these functions shouldn't be free
functions at all, but that's a patch for another day.

  • Scripts/webkitpy/common/checkout/changelog.py:
  • Scripts/webkitpy/common/checkout/changelog_unittest.py:
  • Scripts/webkitpy/common/checkout/checkout.py:
  • Scripts/webkitpy/common/config/urls.py:
  • Scripts/webkitpy/common/net/bugzilla/init.py:
  • Scripts/webkitpy/common/net/bugzilla/bugzilla.py:
  • Scripts/webkitpy/common/net/bugzilla/bugzilla_unittest.py:
  • Scripts/webkitpy/style/checkers/changelog.py:
  • Scripts/webkitpy/tool/bot/irc_command.py:
  • Scripts/webkitpy/tool/bot/sheriff.py:
  • Scripts/webkitpy/tool/commands/upload.py:
Location:
trunk/Tools
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r85723 r85727  
     12011-05-04  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Fix circular dependency in webkitpy
     6        https://bugs.webkit.org/show_bug.cgi?id=60075
     7
     8        These functions don't belong in bugzilla.py.  They only exist there
     9        because they are old.  Really, these functions shouldn't be free
     10        functions at all, but that's a patch for another day.
     11
     12        * Scripts/webkitpy/common/checkout/changelog.py:
     13        * Scripts/webkitpy/common/checkout/changelog_unittest.py:
     14        * Scripts/webkitpy/common/checkout/checkout.py:
     15        * Scripts/webkitpy/common/config/urls.py:
     16        * Scripts/webkitpy/common/net/bugzilla/__init__.py:
     17        * Scripts/webkitpy/common/net/bugzilla/bugzilla.py:
     18        * Scripts/webkitpy/common/net/bugzilla/bugzilla_unittest.py:
     19        * Scripts/webkitpy/style/checkers/changelog.py:
     20        * Scripts/webkitpy/tool/bot/irc_command.py:
     21        * Scripts/webkitpy/tool/bot/sheriff.py:
     22        * Scripts/webkitpy/tool/commands/upload.py:
     23
    1242011-05-03  Pratik Solanki  <psolanki@apple.com>
    225
  • trunk/Tools/Scripts/webkitpy/common/checkout/changelog.py

    r85065 r85727  
    3535import textwrap
    3636
     37from webkitpy.common.config.committers import CommitterList
     38import webkitpy.common.config.urls as config_urls
    3739from webkitpy.common.system.deprecated_logging import log
    38 from webkitpy.common.config.committers import CommitterList
    39 from webkitpy.common.net.bugzilla import parse_bug_id_from_changelog
     40
     41
     42# FIXME: parse_bug_id should not be a free function.
     43# FIXME: Where should this function live in the dependency graph?
     44def parse_bug_id(message):
     45    if not message:
     46        return None
     47    match = re.search(config_urls.bug_url_short, message)
     48    if match:
     49        return int(match.group('bug_id'))
     50    match = re.search(config_urls.bug_url_long, message)
     51    if match:
     52        return int(match.group('bug_id'))
     53    return None
     54
     55
     56# FIXME: parse_bug_id_from_changelog should not be a free function.
     57# Parse the bug ID out of a Changelog message based on the format that is
     58# used by prepare-ChangeLog
     59def parse_bug_id_from_changelog(message):
     60    if not message:
     61        return None
     62    match = re.search("^\s*" + config_urls.bug_url_short + "$", message, re.MULTILINE)
     63    if match:
     64        return int(match.group('bug_id'))
     65    match = re.search("^\s*" + config_urls.bug_url_long + "$", message, re.MULTILINE)
     66    if match:
     67        return int(match.group('bug_id'))
     68    # We weren't able to find a bug URL in the format used by prepare-ChangeLog. Fall back to the
     69    # first bug URL found anywhere in the message.
     70    return parse_bug_id(message)
    4071
    4172
  • trunk/Tools/Scripts/webkitpy/common/checkout/changelog_unittest.py

    r78777 r85727  
    9292"""
    9393
     94    def test_parse_bug_id_from_changelog(self):
     95        commit_text = '''
     962011-03-23  Ojan Vafai  <ojan@chromium.org>
     97
     98        Add failing result for WebKit2. All tests that require
     99        focus fail on WebKit2. See https://bugs.webkit.org/show_bug.cgi?id=56988.
     100
     101        * platform/mac-wk2/fast/css/pseudo-any-expected.txt: Added.
     102
     103        '''
     104
     105        self.assertEquals(56988, parse_bug_id_from_changelog(commit_text))
     106
     107        commit_text = '''
     1082011-03-23  Ojan Vafai  <ojan@chromium.org>
     109
     110        Add failing result for WebKit2. All tests that require
     111        focus fail on WebKit2. See https://bugs.webkit.org/show_bug.cgi?id=56988.
     112        https://bugs.webkit.org/show_bug.cgi?id=12345
     113
     114        * platform/mac-wk2/fast/css/pseudo-any-expected.txt: Added.
     115
     116        '''
     117
     118        self.assertEquals(12345, parse_bug_id_from_changelog(commit_text))
     119
     120        commit_text = '''
     1212011-03-31  Adam Roben  <aroben@apple.com>
     122
     123        Quote the executable path we pass to ::CreateProcessW
     124
     125        This will ensure that spaces in the path will be interpreted correctly.
     126
     127        Fixes <http://webkit.org/b/57569> Web process sometimes fails to launch when there are
     128        spaces in its path
     129
     130        Reviewed by Steve Falkenburg.
     131
     132        * UIProcess/Launcher/win/ProcessLauncherWin.cpp:
     133        (WebKit::ProcessLauncher::launchProcess): Surround the executable path in quotes.
     134
     135        '''
     136
     137        self.assertEquals(57569, parse_bug_id_from_changelog(commit_text))
     138
    94139    def test_latest_entry_parse(self):
    95140        changelog_contents = u"%s\n%s" % (self._example_entry, self._example_changelog)
  • trunk/Tools/Scripts/webkitpy/common/checkout/checkout.py

    r85452 r85727  
    3131
    3232from webkitpy.common.config import urls
    33 from webkitpy.common.checkout.changelog import ChangeLog
     33from webkitpy.common.checkout.changelog import ChangeLog, parse_bug_id_from_changelog
    3434from webkitpy.common.checkout.commitinfo import CommitInfo
    3535from webkitpy.common.checkout.scm import CommitMessage
    3636from webkitpy.common.checkout.deps import DEPS
    3737from webkitpy.common.memoized import memoized
    38 from webkitpy.common.net.bugzilla import parse_bug_id_from_changelog
    3938from webkitpy.common.system.executive import Executive, run_command, ScriptError
    4039from webkitpy.common.system.deprecated_logging import log
  • trunk/Tools/Scripts/webkitpy/common/config/urls.py

    r76926 r85727  
    2727# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2828
     29import re
     30
    2931
    3032def view_source_url(local_path):
     
    3537    return "http://trac.webkit.org/changeset/%s" % revision_number
    3638
     39
    3740chromium_lkgr_url = "http://chromium-status.appspot.com/lkgr"
    3841
    3942contribution_guidelines = "http://webkit.org/coding/contributing.html"
     43
     44bug_server_host = "bugs.webkit.org"
     45_bug_server_regex = "https?://%s/" % re.sub('\.', '\\.', bug_server_host)
     46bug_server_url = "https://%s/" % bug_server_host
     47bug_url_long = _bug_server_regex + r"show_bug\.cgi\?id=(?P<bug_id>\d+)(&ctype=xml)?"
     48bug_url_short = r"http\://webkit\.org/b/(?P<bug_id>\d+)"
  • trunk/Tools/Scripts/webkitpy/common/net/bugzilla/__init__.py

    r82196 r85727  
    22
    33# We only export public API here.
    4 # FIXME: parse_bug_id should not be a free function.
    5 from .bugzilla import Bugzilla, parse_bug_id, parse_bug_id_from_changelog
     4from .bugzilla import Bugzilla
    65# Unclear if Bug and Attachment need to be public classes.
    76from .bug import Bug
  • trunk/Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla.py

    r85080 r85727  
    4444from webkitpy.common.system.deprecated_logging import log
    4545from webkitpy.common.config import committers
     46import webkitpy.common.config.urls as config_urls
    4647from webkitpy.common.net.credentials import Credentials
    4748from webkitpy.common.system.user import User
    4849from webkitpy.thirdparty.BeautifulSoup import BeautifulSoup, BeautifulStoneSoup, SoupStrainer
    4950
    50 
    51 # FIXME: parse_bug_id should not be a free function.
    52 def parse_bug_id(message):
    53     if not message:
    54         return None
    55     match = re.search(Bugzilla.bug_url_short, message)
    56     if match:
    57         return int(match.group('bug_id'))
    58     match = re.search(Bugzilla.bug_url_long, message)
    59     if match:
    60         return int(match.group('bug_id'))
    61     return None
    62 
    63 
    64 # FIXME: parse_bug_id_from_changelog should not be a free function.
    65 # Parse the bug ID out of a Changelog message based on the format that is
    66 # used by prepare-ChangeLog
    67 def parse_bug_id_from_changelog(message):
    68     if not message:
    69         return None
    70     match = re.search("^\s*" + Bugzilla.bug_url_short + "$", message, re.MULTILINE)
    71     if match:
    72         return int(match.group('bug_id'))
    73     match = re.search("^\s*" + Bugzilla.bug_url_long + "$", message, re.MULTILINE)
    74     if match:
    75         return int(match.group('bug_id'))
    76     # We weren't able to find a bug URL in the format used by prepare-ChangeLog. Fall back to the
    77     # first bug URL found anywhere in the message.
    78     return parse_bug_id(message)
    7951
    8052def timestamp():
     
    10880    def _load_query(self, query):
    10981        self._bugzilla.authenticate()
    110         full_url = "%s%s" % (self._bugzilla.bug_server_url, query)
     82        full_url = "%s%s" % (config_urls.bug_server_url, query)
    11183        return self._bugzilla.browser.open(full_url)
    11284
     
    221193        self.browser.set_handle_robots(False)
    222194
    223     # FIXME: Much of this should go into some sort of config module,
    224     # such as common.config.urls.
    225     bug_server_host = "bugs.webkit.org"
    226     bug_server_regex = "https?://%s/" % re.sub('\.', '\\.', bug_server_host)
    227     bug_server_url = "https://%s/" % bug_server_host
    228     bug_url_long = bug_server_regex + r"show_bug\.cgi\?id=(?P<bug_id>\d+)(&ctype=xml)?"
    229     bug_url_short = r"http\://webkit\.org/b/(?P<bug_id>\d+)"
    230 
    231195    def quips(self):
    232196        # We only fetch and parse the list of quips once per instantiation
     
    240204            return None
    241205        content_type = "&ctype=xml" if xml else ""
    242         return "%sshow_bug.cgi?id=%s%s" % (self.bug_server_url, bug_id, content_type)
     206        return "%sshow_bug.cgi?id=%s%s" % (config_urls.bug_server_url, bug_id, content_type)
    243207
    244208    def short_bug_url_for_bug_id(self, bug_id):
     
    248212
    249213    def add_attachment_url(self, bug_id):
    250         return "%sattachment.cgi?action=enter&bugid=%s" % (self.bug_server_url, bug_id)
     214        return "%sattachment.cgi?action=enter&bugid=%s" % (config_urls.bug_server_url, bug_id)
    251215
    252216    def attachment_url_for_id(self, attachment_id, action="view"):
     
    256220        if action and action != "view":
    257221            action_param = "&action=%s" % action
    258         return "%sattachment.cgi?id=%s%s" % (self.bug_server_url,
     222        return "%sattachment.cgi?id=%s%s" % (config_urls.bug_server_url,
    259223                                             attachment_id,
    260224                                             action_param)
     
    406370            return
    407371
    408         credentials = Credentials(self.bug_server_host, git_prefix="bugzilla")
     372        credentials = Credentials(config_urls.bug_server_host, git_prefix="bugzilla")
    409373
    410374        attempts = 0
     
    414378
    415379            log("Logging in as %s..." % username)
    416             self.browser.open(self.bug_server_url +
     380            self.browser.open(config_urls.bug_server_url +
    417381                              "index.cgi?GoAheadAndLogIn=1")
    418382            self.browser.select_form(name="login")
     
    575539            return
    576540
    577         self.browser.open(self.bug_server_url + "enter_bug.cgi?product=WebKit")
     541        self.browser.open(config_urls.bug_server_url + "enter_bug.cgi?product=WebKit")
    578542        self.browser.select_form(name="Create")
    579543        component_items = self.browser.find_control('component').items
     
    611575        bug_id = self._check_create_bug_response(response.read())
    612576        log("Bug %s created." % bug_id)
    613         log("%sshow_bug.cgi?id=%s" % (self.bug_server_url, bug_id))
     577        log("%sshow_bug.cgi?id=%s" % (config_urls.bug_server_url, bug_id))
    614578        return bug_id
    615579
  • trunk/Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla_unittest.py

    r82766 r85727  
    3131import StringIO
    3232
    33 from .bugzilla import Bugzilla, BugzillaQueries, parse_bug_id, parse_bug_id_from_changelog
    34 
     33from .bugzilla import Bugzilla, BugzillaQueries
     34
     35from webkitpy.common.checkout.changelog import parse_bug_id
    3536from webkitpy.common.system.outputcapture import OutputCapture
    3637from webkitpy.tool.mocktool import MockBrowser
     
    192193        }],
    193194    }
    194 
    195     def test_parse_bug_id_from_changelog(self):
    196         commit_text = '''
    197 2011-03-23  Ojan Vafai  <ojan@chromium.org>
    198 
    199         Add failing result for WebKit2. All tests that require
    200         focus fail on WebKit2. See https://bugs.webkit.org/show_bug.cgi?id=56988.
    201 
    202         * platform/mac-wk2/fast/css/pseudo-any-expected.txt: Added.
    203 
    204         '''
    205 
    206         self.assertEquals(56988, parse_bug_id_from_changelog(commit_text))
    207 
    208         commit_text = '''
    209 2011-03-23  Ojan Vafai  <ojan@chromium.org>
    210 
    211         Add failing result for WebKit2. All tests that require
    212         focus fail on WebKit2. See https://bugs.webkit.org/show_bug.cgi?id=56988.
    213         https://bugs.webkit.org/show_bug.cgi?id=12345
    214 
    215         * platform/mac-wk2/fast/css/pseudo-any-expected.txt: Added.
    216 
    217         '''
    218 
    219         self.assertEquals(12345, parse_bug_id_from_changelog(commit_text))
    220 
    221         commit_text = '''
    222 2011-03-31  Adam Roben  <aroben@apple.com>
    223 
    224         Quote the executable path we pass to ::CreateProcessW
    225 
    226         This will ensure that spaces in the path will be interpreted correctly.
    227 
    228         Fixes <http://webkit.org/b/57569> Web process sometimes fails to launch when there are
    229         spaces in its path
    230 
    231         Reviewed by Steve Falkenburg.
    232 
    233         * UIProcess/Launcher/win/ProcessLauncherWin.cpp:
    234         (WebKit::ProcessLauncher::launchProcess): Surround the executable path in quotes.
    235 
    236         '''
    237 
    238         self.assertEquals(57569, parse_bug_id_from_changelog(commit_text))
    239 
    240195
    241196    # FIXME: This should move to a central location and be shared by more unit tests.
  • trunk/Tools/Scripts/webkitpy/style/checkers/changelog.py

    r82382 r85727  
    2828import re
    2929from common import TabChecker
    30 from webkitpy.common.net.bugzilla import parse_bug_id_from_changelog
     30from webkitpy.common.checkout.changelog import parse_bug_id_from_changelog
    3131
    3232
  • trunk/Tools/Scripts/webkitpy/tool/bot/irc_command.py

    r85065 r85727  
    3232from webkitpy.common.config import urls
    3333from webkitpy.common.config.committers import CommitterList
    34 from webkitpy.common.net.bugzilla import parse_bug_id
     34from webkitpy.common.checkout.changelog import parse_bug_id
    3535from webkitpy.common.system.executive import ScriptError
    3636from webkitpy.tool.bot.queueengine import TerminateQueue
  • trunk/Tools/Scripts/webkitpy/tool/bot/sheriff.py

    r75063 r85727  
    2828
    2929from webkitpy.common.config import urls
    30 from webkitpy.common.net.bugzilla import parse_bug_id
     30from webkitpy.common.checkout.changelog import parse_bug_id
    3131from webkitpy.common.system.deprecated_logging import log
    3232from webkitpy.common.system.executive import ScriptError
  • trunk/Tools/Scripts/webkitpy/tool/commands/upload.py

    r82196 r85727  
    3737from webkitpy.tool import steps
    3838
     39from webkitpy.common.checkout.changelog import parse_bug_id_from_changelog
    3940from webkitpy.common.config.committers import CommitterList
    40 from webkitpy.common.net.bugzilla import parse_bug_id_from_changelog
    4141from webkitpy.common.system.deprecated_logging import error, log
    4242from webkitpy.common.system.user import User
Note: See TracChangeset for help on using the changeset viewer.