Commit 034a666b authored by eric@webkit.org's avatar eric@webkit.org
Browse files

Add a land-from-url command

https://bugs.webkit.org/show_bug.cgi?id=81411

Reviewed by Adam Barth.

Very basic so far.  The goal is to make it landing smarter
so that users don't have to bother to parse out the ids out of the urls.

* Scripts/webkitpy/common/config/urls.py:
(parse_bug_id):
(parse_attachment_id):
* Scripts/webkitpy/common/config/urls_unittest.py:
(URLsTest.test_parse_bug_id):
(URLsTest):
(URLsTest.test_parse_attachment_id):
* Scripts/webkitpy/tool/commands/download.py:
(ProcessURLsMixin):
(ProcessURLsMixin._fetch_list_of_patches_to_process):
(LandFromURL):
* Scripts/webkitpy/tool/commands/download_unittest.py:
(test_land_from_bug):
(test_land_from_url):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@111095 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent f16994f1
2012-03-16 Eric Seidel <eric@webkit.org>
Add a land-from-url command
https://bugs.webkit.org/show_bug.cgi?id=81411
Reviewed by Adam Barth.
Very basic so far. The goal is to make it landing smarter
so that users don't have to bother to parse out the ids out of the urls.
* Scripts/webkitpy/common/config/urls.py:
(parse_bug_id):
(parse_attachment_id):
* Scripts/webkitpy/common/config/urls_unittest.py:
(URLsTest.test_parse_bug_id):
(URLsTest):
(URLsTest.test_parse_attachment_id):
* Scripts/webkitpy/tool/commands/download.py:
(ProcessURLsMixin):
(ProcessURLsMixin._fetch_list_of_patches_to_process):
(LandFromURL):
* Scripts/webkitpy/tool/commands/download_unittest.py:
(test_land_from_bug):
(test_land_from_url):
2012-03-16 Dave Tharp <dtharp@codeaurora.org>
 
build-webkit launcher instructions use wrong relative path for Qt
......@@ -43,23 +43,39 @@ def chromium_results_zip_url(builder_name):
chromium_lkgr_url = "http://chromium-status.appspot.com/lkgr"
contribution_guidelines = "http://webkit.org/coding/contributing.html"
bug_server_host = "bugs.webkit.org"
bug_server_domain = "webkit.org"
bug_server_host = "bugs." + bug_server_domain
_bug_server_regex = "https?://%s/" % re.sub('\.', '\\.', bug_server_host)
bug_server_url = "https://%s/" % bug_server_host
bug_url_long = _bug_server_regex + r"show_bug\.cgi\?id=(?P<bug_id>\d+)(&ctype=xml)?"
bug_url_short = r"https?\://webkit\.org/b/(?P<bug_id>\d+)"
bug_url_short = r"https?\://%s/b/(?P<bug_id>\d+)" % bug_server_domain
attachment_url = _bug_server_regex + r"attachment\.cgi\?id=(?P<attachment_id>\d+)(&action=(?P<action>\w+))?"
direct_attachment_url = r"https?://bug-(?P<bug_id>\d+)-attachments.%s/attachment\.cgi\?id=(?P<attachment_id>\d+)" % bug_server_domain
buildbot_url = "http://build.webkit.org"
chromium_buildbot_url = "http://build.chromium.org/p/chromium.webkit"
def parse_bug_id(message):
if not message:
def parse_bug_id(string):
if not string:
return None
match = re.search(bug_url_short, message)
match = re.search(bug_url_short, string)
if match:
return int(match.group('bug_id'))
match = re.search(bug_url_long, message)
match = re.search(bug_url_long, string)
if match:
return int(match.group('bug_id'))
return None
def parse_attachment_id(string):
if not string:
return None
match = re.search(attachment_url, string)
if match:
return int(match.group('attachment_id'))
match = re.search(direct_attachment_url, string)
if match:
return int(match.group('attachment_id'))
return None
......@@ -28,7 +28,7 @@
import unittest
from .urls import parse_bug_id
from .urls import parse_bug_id, parse_attachment_id
class URLsTest(unittest.TestCase):
......@@ -41,3 +41,14 @@ class URLsTest(unittest.TestCase):
# 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"))
def test_parse_attachment_id(self):
self.assertEquals(12345, parse_attachment_id("https://bugs.webkit.org/attachment.cgi?id=12345&action=review"))
self.assertEquals(12345, parse_attachment_id("https://bugs.webkit.org/attachment.cgi?id=12345&action=edit"))
self.assertEquals(12345, parse_attachment_id("https://bugs.webkit.org/attachment.cgi?id=12345&action=prettypatch"))
self.assertEquals(12345, parse_attachment_id("https://bugs.webkit.org/attachment.cgi?id=12345&action=diff"))
# Direct attachment links are hosted from per-bug subdomains:
self.assertEquals(12345, parse_attachment_id("https://bug-23456-attachments.webkit.org/attachment.cgi?id=12345"))
# Make sure secure attachment URLs work too.
self.assertEquals(12345, parse_attachment_id("https://bug-23456-attachments.webkit.org/attachment.cgi?id=12345&t=Bqnsdkl9fs"))
......@@ -202,6 +202,23 @@ class ProcessBugsMixin(object):
return all_patches
class ProcessURLsMixin(object):
def _fetch_list_of_patches_to_process(self, options, args, tool):
all_patches = []
for url in args:
bug_id = urls.parse_bug_id(url)
if bug_id:
patches = tool.bugs.fetch_bug(bug_id).patches()
log("%s found on bug %s." % (pluralize("patch", len(patches)), bug_id))
all_patches += patches
attachment_id = urls.parse_attachment_id(url)
if attachment_id:
all_patches += tool.bugs.fetch_attachment(attachment_id)
return all_patches
class CheckStyle(AbstractPatchSequencingCommand, ProcessAttachmentsMixin):
name = "check-style"
help_text = "Run check-webkit-style on the specified attachments"
......@@ -317,6 +334,12 @@ class LandFromBug(AbstractPatchLandingCommand, ProcessBugsMixin):
show_in_main_help = True
class LandFromURL(AbstractPatchLandingCommand, ProcessURLsMixin):
name = "land-from-url"
help_text = "Land all patches on the given URLs, optionally building and testing them first"
argument_names = "URL [URLS]"
class ValidateChangelog(AbstractSequencedCommand):
name = "validate-changelog"
help_text = "Validate that the ChangeLogs and reviewers look reasonable"
......
......@@ -193,7 +193,7 @@ Not closing bug 50000 as attachment 10000 has review=+. Assuming there are more
"""
self.assert_execute_outputs(LandAttachment(), [10000], options=self._default_options(), expected_stderr=expected_stderr)
def test_land_patches(self):
def test_land_from_bug(self):
# FIXME: This expected result is imperfect, notice how it's seeing the same patch as still there after it thought it would have cleared the flags.
expected_stderr = """2 reviewed patches found on bug 50000.
Processing 2 patches from 1 bug.
......@@ -220,6 +220,33 @@ Not closing bug 50000 as attachment 10000 has review=+. Assuming there are more
"""
self.assert_execute_outputs(LandFromBug(), [50000], options=self._default_options(), expected_stderr=expected_stderr)
def test_land_from_url(self):
# FIXME: This expected result is imperfect, notice how it's seeing the same patch as still there after it thought it would have cleared the flags.
expected_stderr = """2 patches found on bug 50000.
Processing 2 patches from 1 bug.
Updating working directory
Processing patch 10000 from bug 50000.
Building WebKit
Running Python unit tests
Running Perl unit tests
Running JavaScriptCore tests
Running WebKit unit tests
Running run-webkit-tests
Committed r49824: <http://trac.webkit.org/changeset/49824>
Not closing bug 50000 as attachment 10000 has review=+. Assuming there are more patches to land from this bug.
Updating working directory
Processing patch 10001 from bug 50000.
Building WebKit
Running Python unit tests
Running Perl unit tests
Running JavaScriptCore tests
Running WebKit unit tests
Running run-webkit-tests
Committed r49824: <http://trac.webkit.org/changeset/49824>
Not closing bug 50000 as attachment 10000 has review=+. Assuming there are more patches to land from this bug.
"""
self.assert_execute_outputs(LandFromURL(), ["https://bugs.webkit.org/show_bug.cgi?id=50000"], options=self._default_options(), expected_stderr=expected_stderr)
def test_prepare_rollout(self):
expected_stderr = "Preparing rollout for bug 50000.\nUpdating working directory\n"
self.assert_execute_outputs(PrepareRollout(), [852, "Reason"], options=self._default_options(), expected_stderr=expected_stderr)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment