Changeset 90968 in webkit
- Timestamp:
- Jul 13, 2011 6:39:12 PM (13 years ago)
- Location:
- trunk/Tools
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r90967 r90968 1 2011-07-13 Adam Barth <abarth@webkit.org> 2 3 gardening server should have an API for parsing changelogs 4 https://bugs.webkit.org/show_bug.cgi?id=64495 5 6 Reviewed by Eric Seidel. 7 8 This patch exposes much of the same information from CommitInfo in a 9 dictionary form, which is easier to send over-the-wire as JSON to the 10 frontend. 11 12 * Scripts/webkitpy/common/checkout/checkout.py: 13 * Scripts/webkitpy/common/checkout/checkout_unittest.py: 14 * Scripts/webkitpy/tool/mocktool.py: 15 * Scripts/webkitpy/tool/servers/gardeningserver.py: 16 * Scripts/webkitpy/tool/servers/gardeningserver_unittest.py: 17 * Scripts/webkitpy/tool/servers/reflectionhandler.py: 18 1 19 2011-07-13 Eric Seidel <eric@webkit.org> 2 20 -
trunk/Tools/Scripts/webkitpy/common/checkout/checkout.py
r90967 r90968 59 59 return ChangeLog.parse_latest_entry_from_file(changelog_file) 60 60 61 def changelog_entries_for_revision(self, revision): 62 changed_files = self._scm.changed_files_for_revision(revision) 61 def changelog_entries_for_revision(self, revision, changed_files=None): 62 if not changed_files: 63 changed_files = self._scm.changed_files_for_revision(revision) 63 64 # FIXME: This gets confused if ChangeLog files are moved, as 64 65 # deletes are still "changed files" per changed_files_for_revision. … … 75 76 return changelog_entries 76 77 77 @memoized 78 def commit_info_for_revision(self, revision): 79 committer_email = self._scm.committer_email_for_revision(revision) 80 changelog_entries = self.changelog_entries_for_revision(revision) 78 def _changelog_data_for_revision(self, revision): 79 changed_files = self._scm.changed_files_for_revision(revision) 80 changelog_entries = self.changelog_entries_for_revision(revision, changed_files=changed_files) 81 81 # Assume for now that the first entry has everything we need: 82 82 # FIXME: This will throw an exception if there were no ChangeLogs. … … 84 84 return None 85 85 changelog_entry = changelog_entries[0] 86 changelog_data ={86 return { 87 87 "bug_id": parse_bug_id_from_changelog(changelog_entry.contents()), 88 88 "author_name": changelog_entry.author_name(), … … 91 91 "reviewer_text": changelog_entry.reviewer_text(), 92 92 "reviewer": changelog_entry.reviewer(), 93 "contents": changelog_entry.contents(), 94 "changed_files": changed_files, 93 95 } 94 # We could pass the changelog_entry instead of a dictionary here, but that makes 95 # mocking slightly more involved, and would make aggregating data from multiple 96 # entries more difficult to wire in if we need to do that in the future. 96 97 @memoized 98 def commit_info_for_revision(self, revision): 99 committer_email = self._scm.committer_email_for_revision(revision) 100 changelog_data = self._changelog_data_for_revision(revision) 101 if not changelog_data: 102 return None 97 103 return CommitInfo(revision, committer_email, changelog_data) 98 104 -
trunk/Tools/Scripts/webkitpy/common/checkout/checkout_unittest.py
r90659 r90968 179 179 def test_commit_info_for_revision(self): 180 180 scm = Mock() 181 scm.committer_email_for_revision = lambda revision: "committer@example.com" 182 checkout = Checkout(scm) 183 checkout.changelog_entries_for_revision = lambda revision: [ChangeLogEntry(_changelog1entry1)] 181 scm.changed_files_for_revision = lambda revision: ['path/to/file', 'another/file'] 182 scm.committer_email_for_revision = lambda revision, changed_files=None: "committer@example.com" 183 checkout = Checkout(scm) 184 checkout.changelog_entries_for_revision = lambda revision, changed_files=None: [ChangeLogEntry(_changelog1entry1)] 184 185 commitinfo = checkout.commit_info_for_revision(4) 185 186 self.assertEqual(commitinfo.bug_id(), 36629) … … 190 191 self.assertEqual(commitinfo.committer_email(), "committer@example.com") 191 192 self.assertEqual(commitinfo.committer(), None) 192 193 checkout.changelog_entries_for_revision = lambda revision: [] 193 self.assertEqual(commitinfo.to_json(), { 194 'bug_id': 36629, 195 'author_email': 'vestbo@webkit.org', 196 'changed_files': [ 197 'path/to/file', 198 'another/file', 199 ], 200 'reviewer_text': None, 201 'author_name': u'Tor Arne Vestb\xf8', 202 }) 203 204 checkout.changelog_entries_for_revision = lambda revision, changed_files=None: [] 194 205 self.assertEqual(checkout.commit_info_for_revision(1), None) 195 206 … … 198 209 scm.committer_email_for_revision = lambda revision: "committer@example.com" 199 210 checkout = Checkout(scm) 200 checkout.changelog_entries_for_revision = lambda revision : [ChangeLogEntry(_changelog1entry1)]211 checkout.changelog_entries_for_revision = lambda revision, changed_files=None: [ChangeLogEntry(_changelog1entry1)] 201 212 self.assertEqual(checkout.bug_id_for_revision(4), 36629) 202 213 … … 216 227 217 228 def test_suggested_reviewers(self): 218 def mock_changelog_entries_for_revision(revision ):229 def mock_changelog_entries_for_revision(revision, changed_files=None): 219 230 if revision % 2 == 0: 220 231 return [ChangeLogEntry(_changelog1entry1)] -
trunk/Tools/Scripts/webkitpy/common/checkout/commitinfo.py
r73691 r90968 37 37 self._revision = revision 38 38 self._committer_email = committer_email 39 self._bug_id = changelog_data["bug_id"] 40 self._author_name = changelog_data["author_name"] 41 self._author_email = changelog_data["author_email"] 42 self._author = changelog_data["author"] 43 self._reviewer_text = changelog_data["reviewer_text"] 44 self._reviewer = changelog_data["reviewer"] 39 self._changelog_data = changelog_data 45 40 46 41 # Derived values: … … 57 52 58 53 def bug_id(self): 59 return self._ bug_id# May be None54 return self._changelog_data["bug_id"] # May be None 60 55 61 56 def author(self): 62 return self._ author# May be None57 return self._changelog_data["author"] # May be None 63 58 64 59 def author_name(self): 65 return self._ author_name60 return self._changelog_data["author_name"] 66 61 67 62 def author_email(self): 68 return self._ author_email63 return self._changelog_data["author_email"] 69 64 70 65 def reviewer(self): 71 return self._ reviewer# May be None66 return self._changelog_data["reviewer"] # May be None 72 67 73 68 def reviewer_text(self): 74 return self._reviewer_text # May be None 69 return self._changelog_data["reviewer_text"] # May be None 70 71 def changed_files(self): 72 return self._changelog_data["changed_files"] 73 74 def to_json(self): 75 return { 76 "bug_id": self.bug_id(), 77 "author_name": self.author_name(), 78 "author_email": self.author_email(), 79 "reviewer_text": self.reviewer_text(), 80 "changed_files": self.changed_files(), 81 } 75 82 76 83 def responsible_parties(self): -
trunk/Tools/Scripts/webkitpy/tool/mocktool.py
r90770 r90968 544 544 "reviewer_text": "Darin Adler", 545 545 "reviewer": self._committer_list.committer_by_name("Darin Adler"), 546 "changed_files": [ 547 "path/to/file", 548 "another/file", 549 ], 546 550 }) 547 551 -
trunk/Tools/Scripts/webkitpy/tool/servers/gardeningserver.py
r90880 r90968 56 56 return self.server.tool.executive.run_command([self.server.tool.path()] + args) 57 57 58 def changelog(self): 59 revision = self.query['revision'][0] 60 head_revision = self.server.tool.scm().head_svn_revision() 61 if revision > head_revision: 62 # Updating the working copy could conflict with any rebaselines we have in progress. 63 update_webkit_command = self.server.tool.port().update_webkit_command() 64 self.server.tool.executive.run_and_throw_if_fail(update_webkit_command, quiet=True) 65 commit_info = self.server.tool.checkout().commit_info_for_revision(revision) 66 if not commit_info: 67 self.send_error(404, "File not found") 68 else: 69 self._serve_json(commit_info.to_json()) 70 58 71 def rollout(self): 59 72 revision = self.query['revision'][0] -
trunk/Tools/Scripts/webkitpy/tool/servers/gardeningserver_unittest.py
r90774 r90968 27 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 28 29 try: 30 import json 31 except ImportError: 32 # python 2.5 compatibility 33 import webkitpy.thirdparty.simplejson as json 34 29 35 import unittest 30 36 … … 52 58 print "== End Response ==" 53 59 60 def _serve_json(self, json_object): 61 print "== Begin JSON Response ==" 62 print json.dumps(json_object) 63 print "== End JSON Response ==" 64 54 65 55 66 class GardeningServerTest(unittest.TestCase): … … 59 70 OutputCapture().assert_outputs(self, handler.do_POST, expected_stderr=expected_stderr, expected_stdout=expected_stdout) 60 71 72 def test_changelog(self): 73 expected_stderr = "MOCK run_and_throw_if_fail: ['mock-update-webkit']\n" 74 expected_stdout = """== Begin JSON Response == 75 {"bug_id": 42, "author_email": "abarth@webkit.org", "reviewer_text": "Darin Adler", "author_name": "Adam Barth", "changed_files": ["path/to/file", "another/file"]} 76 == End JSON Response == 77 """ 78 self._post_to_path("/changelog?revision=2314", expected_stderr=expected_stderr, expected_stdout=expected_stdout) 79 61 80 def test_rollout(self): 62 81 expected_stderr = "MOCK run_command: ['echo', 'rollout', '--force-clean', '--non-interactive', '2314', 'MOCK rollout reason']\n" … … 64 83 self._post_to_path("/rollout?revision=2314&reason=MOCK+rollout+reason", expected_stderr=expected_stderr, expected_stdout=expected_stdout) 65 84 66 def test_rebaseline _test(self):85 def test_rebaseline(self): 67 86 expected_stderr = "MOCK run_command: ['echo', 'rebaseline-test', 'MOCK builder', 'user-scripts/another-test.html', 'txt']\n" 68 87 expected_stdout = "== Begin Response ==\nsuccess\n== End Response ==\n" -
trunk/Tools/Scripts/webkitpy/tool/servers/reflectionhandler.py
r90774 r90968 28 28 29 29 from __future__ import with_statement 30 31 try: 32 import json 33 except ImportError: 34 # python 2.5 compatibility 35 import webkitpy.thirdparty.simplejson as json 30 36 31 37 import BaseHTTPServer … … 93 99 self.wfile.write(text) 94 100 95 def _serve_json(self, json ):101 def _serve_json(self, json_object): 96 102 self.send_response(200) 97 103 self.send_header('Content-type', 'application/json') 98 104 self.end_headers() 99 simplejson.dump(json, self.wfile)105 json.dump(json_object, self.wfile) 100 106 101 107 def _serve_file(self, file_path, cacheable_seconds=0):
Note: See TracChangeset
for help on using the changeset viewer.