Changeset 90968 in webkit


Ignore:
Timestamp:
Jul 13, 2011 6:39:12 PM (13 years ago)
Author:
abarth@webkit.org
Message:

gardening server should have an API for parsing changelogs
https://bugs.webkit.org/show_bug.cgi?id=64495

Reviewed by Eric Seidel.

This patch exposes much of the same information from CommitInfo in a
dictionary form, which is easier to send over-the-wire as JSON to the
frontend.

  • Scripts/webkitpy/common/checkout/checkout.py:
  • Scripts/webkitpy/common/checkout/checkout_unittest.py:
  • Scripts/webkitpy/tool/mocktool.py:
  • Scripts/webkitpy/tool/servers/gardeningserver.py:
  • Scripts/webkitpy/tool/servers/gardeningserver_unittest.py:
  • Scripts/webkitpy/tool/servers/reflectionhandler.py:
Location:
trunk/Tools
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r90967 r90968  
     12011-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
    1192011-07-13  Eric Seidel  <eric@webkit.org>
    220
  • trunk/Tools/Scripts/webkitpy/common/checkout/checkout.py

    r90967 r90968  
    5959        return ChangeLog.parse_latest_entry_from_file(changelog_file)
    6060
    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)
    6364        # FIXME: This gets confused if ChangeLog files are moved, as
    6465        # deletes are still "changed files" per changed_files_for_revision.
     
    7576        return changelog_entries
    7677
    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)
    8181        # Assume for now that the first entry has everything we need:
    8282        # FIXME: This will throw an exception if there were no ChangeLogs.
     
    8484            return None
    8585        changelog_entry = changelog_entries[0]
    86         changelog_data = {
     86        return {
    8787            "bug_id": parse_bug_id_from_changelog(changelog_entry.contents()),
    8888            "author_name": changelog_entry.author_name(),
     
    9191            "reviewer_text": changelog_entry.reviewer_text(),
    9292            "reviewer": changelog_entry.reviewer(),
     93            "contents": changelog_entry.contents(),
     94            "changed_files": changed_files,
    9395        }
    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
    97103        return CommitInfo(revision, committer_email, changelog_data)
    98104
  • trunk/Tools/Scripts/webkitpy/common/checkout/checkout_unittest.py

    r90659 r90968  
    179179    def test_commit_info_for_revision(self):
    180180        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)]
    184185        commitinfo = checkout.commit_info_for_revision(4)
    185186        self.assertEqual(commitinfo.bug_id(), 36629)
     
    190191        self.assertEqual(commitinfo.committer_email(), "committer@example.com")
    191192        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: []
    194205        self.assertEqual(checkout.commit_info_for_revision(1), None)
    195206
     
    198209        scm.committer_email_for_revision = lambda revision: "committer@example.com"
    199210        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)]
    201212        self.assertEqual(checkout.bug_id_for_revision(4), 36629)
    202213
     
    216227
    217228    def test_suggested_reviewers(self):
    218         def mock_changelog_entries_for_revision(revision):
     229        def mock_changelog_entries_for_revision(revision, changed_files=None):
    219230            if revision % 2 == 0:
    220231                return [ChangeLogEntry(_changelog1entry1)]
  • trunk/Tools/Scripts/webkitpy/common/checkout/commitinfo.py

    r73691 r90968  
    3737        self._revision = revision
    3838        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
    4540
    4641        # Derived values:
     
    5752
    5853    def bug_id(self):
    59         return self._bug_id  # May be None
     54        return self._changelog_data["bug_id"]  # May be None
    6055
    6156    def author(self):
    62         return self._author  # May be None
     57        return self._changelog_data["author"]  # May be None
    6358
    6459    def author_name(self):
    65         return self._author_name
     60        return self._changelog_data["author_name"]
    6661
    6762    def author_email(self):
    68         return self._author_email
     63        return self._changelog_data["author_email"]
    6964
    7065    def reviewer(self):
    71         return self._reviewer # May be None
     66        return self._changelog_data["reviewer"] # May be None
    7267
    7368    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        }
    7582
    7683    def responsible_parties(self):
  • trunk/Tools/Scripts/webkitpy/tool/mocktool.py

    r90770 r90968  
    544544            "reviewer_text": "Darin Adler",
    545545            "reviewer": self._committer_list.committer_by_name("Darin Adler"),
     546            "changed_files": [
     547                "path/to/file",
     548                "another/file",
     549            ],
    546550        })
    547551
  • trunk/Tools/Scripts/webkitpy/tool/servers/gardeningserver.py

    r90880 r90968  
    5656        return self.server.tool.executive.run_command([self.server.tool.path()] + args)
    5757
     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
    5871    def rollout(self):
    5972        revision = self.query['revision'][0]
  • trunk/Tools/Scripts/webkitpy/tool/servers/gardeningserver_unittest.py

    r90774 r90968  
    2727# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2828
     29try:
     30    import json
     31except ImportError:
     32    # python 2.5 compatibility
     33    import webkitpy.thirdparty.simplejson as json
     34
    2935import unittest
    3036
     
    5258        print "== End Response =="
    5359
     60    def _serve_json(self, json_object):
     61        print "== Begin JSON Response =="
     62        print json.dumps(json_object)
     63        print "== End JSON Response =="
     64
    5465
    5566class GardeningServerTest(unittest.TestCase):
     
    5970        OutputCapture().assert_outputs(self, handler.do_POST, expected_stderr=expected_stderr, expected_stdout=expected_stdout)
    6071
     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
    6180    def test_rollout(self):
    6281        expected_stderr = "MOCK run_command: ['echo', 'rollout', '--force-clean', '--non-interactive', '2314', 'MOCK rollout reason']\n"
     
    6483        self._post_to_path("/rollout?revision=2314&reason=MOCK+rollout+reason", expected_stderr=expected_stderr, expected_stdout=expected_stdout)
    6584
    66     def test_rebaseline_test(self):
     85    def test_rebaseline(self):
    6786        expected_stderr = "MOCK run_command: ['echo', 'rebaseline-test', 'MOCK builder', 'user-scripts/another-test.html', 'txt']\n"
    6887        expected_stdout = "== Begin Response ==\nsuccess\n== End Response ==\n"
  • trunk/Tools/Scripts/webkitpy/tool/servers/reflectionhandler.py

    r90774 r90968  
    2828
    2929from __future__ import with_statement
     30
     31try:
     32    import json
     33except ImportError:
     34    # python 2.5 compatibility
     35    import webkitpy.thirdparty.simplejson as json
    3036
    3137import BaseHTTPServer
     
    9399        self.wfile.write(text)
    94100
    95     def _serve_json(self, json):
     101    def _serve_json(self, json_object):
    96102        self.send_response(200)
    97103        self.send_header('Content-type', 'application/json')
    98104        self.end_headers()
    99         simplejson.dump(json, self.wfile)
     105        json.dump(json_object, self.wfile)
    100106
    101107    def _serve_file(self, file_path, cacheable_seconds=0):
Note: See TracChangeset for help on using the changeset viewer.