Changeset 212947 in webkit


Ignore:
Timestamp:
Feb 23, 2017 11:17:48 PM (7 years ago)
Author:
Dewei Zhu
Message:

Rename 'commit_parent' in 'commits' table to 'commit_previous_commit'.
https://bugs.webkit.org/show_bug.cgi?id=168816

Reviewed by Ryosuke Niwa.

Rename 'commit_parent' to avoid ambiguity in the coming feature.
For exisiting database, run

"ALTER TABLE commits RENAME commit_parent TO commit_previous_commit;"

to update the database.

  • init-database.sql:
  • public/api/report-commits.php:
  • public/include/commit-log-fetcher.php:
  • server-tests/api-commits.js:

(then):

  • server-tests/api-report-commits-tests.js:

(then):

  • tools/sync-commits.py:

(main):
(Repository.fetch_commits_and_submit):
(GitRepository._revision_from_tokens):

  • unit-tests/analysis-task-tests.js:

(sampleAnalysisTask):

Location:
trunk/Websites/perf.webkit.org
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Websites/perf.webkit.org/ChangeLog

    r212946 r212947  
     12017-02-23  Dewei Zhu  <dewei_zhu@apple.com>
     2
     3        Rename 'commit_parent' in 'commits' table to 'commit_previous_commit'.
     4        https://bugs.webkit.org/show_bug.cgi?id=168816
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Rename 'commit_parent' to avoid ambiguity in the coming feature.
     9        For exisiting database, run
     10            "ALTER TABLE commits RENAME commit_parent TO commit_previous_commit;"
     11        to update the database.
     12
     13        * init-database.sql:
     14        * public/api/report-commits.php:
     15        * public/include/commit-log-fetcher.php:
     16        * server-tests/api-commits.js:
     17        (then):
     18        * server-tests/api-report-commits-tests.js:
     19        (then):
     20        * tools/sync-commits.py:
     21        (main):
     22        (Repository.fetch_commits_and_submit):
     23        (GitRepository._revision_from_tokens):
     24        * unit-tests/analysis-task-tests.js:
     25        (sampleAnalysisTask):
     26
    1272017-02-23  Ryosuke Niwa  <rniwa@webkit.org>
    228
  • trunk/Websites/perf.webkit.org/init-database.sql

    r202001 r212947  
    8989    commit_repository integer NOT NULL REFERENCES repositories ON DELETE CASCADE,
    9090    commit_revision varchar(64) NOT NULL,
    91     commit_parent integer REFERENCES commits ON DELETE CASCADE,
     91    commit_previous_commit integer REFERENCES commits ON DELETE CASCADE,
    9292    commit_time timestamp,
    9393    commit_order integer,
     
    262262    request_created_at timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC'),
    263263    CONSTRAINT build_request_order_must_be_unique_in_group UNIQUE(request_group, request_order));
    264 CREATE INDEX build_request_triggerable ON build_requests(request_triggerable);   
     264CREATE INDEX build_request_triggerable ON build_requests(request_triggerable);
    265265CREATE INDEX build_request_build ON build_requests(request_build);
  • trunk/Websites/perf.webkit.org/public/api/report-commits.php

    r194088 r212947  
    4848        }
    4949
    50         $parent_revision = array_get($commit_info, 'parent');
    51         $parent_id = NULL;
    52         if ($parent_revision) {
    53             $parent_commit = $db->select_first_row('commits', 'commit', array('repository' => $repository_id, 'revision' => $parent_revision));
    54             if (!$parent_commit) {
     50        $previous_commit_revision = array_get($commit_info, 'previousCommit');
     51        $previous_commit_id = NULL;
     52        if ($previous_commit_revision) {
     53            $previous_commit = $db->select_first_row('commits', 'commit', array('repository' => $repository_id, 'revision' => $previous_commit_revision));
     54            if (!$previous_commit) {
    5555                $db->rollback_transaction();
    56                 exit_with_error('FailedToFindParentCommit', array('commit' => $commit_info));
     56                exit_with_error('FailedToFindPreviousCommit', array('commit' => $commit_info));
    5757            }
    58             $parent_id = $parent_commit['commit_id'];
     58            $previous_commit_id = $previous_commit['commit_id'];
    5959        }
    6060
     
    6262            'repository' => $repository_id,
    6363            'revision' => $commit_info['revision'],
    64             'parent' => $parent_id,
     64            'previous_commit' => $previous_commit_id,
    6565            'order' => array_get($commit_info, 'order'),
    6666            'time' => array_get($commit_info, 'time'),
  • trunk/Websites/perf.webkit.org/public/include/commit-log-fetcher.php

    r210981 r212947  
    3737        $statements = 'SELECT commit_id as "id",
    3838            commit_revision as "revision",
    39             commit_parent as "parent",
     39            commit_previous_commit as "previousCommit",
    4040            commit_time as "time",
    4141            committer_name as "authorName",
     
    122122            'id' => $commit_row['commit_id'],
    123123            'revision' => $commit_row['commit_revision'],
    124             'parent' => $commit_row['commit_parent'],
     124            'previousCommit' => $commit_row['commit_previous_commit'],
    125125            'time' => Database::to_js_time($commit_row['commit_time']),
    126126            'order' => $commit_row['commit_order'],
  • trunk/Websites/perf.webkit.org/server-tests/api-commits.js

    r210981 r212947  
    3131            {
    3232                "repository": "WebKit",
    33                 "parent": "210949",
     33                "previousCommit": "210949",
    3434                "revision": "210950",
    3535                "time": "2017-01-20T03:49:37.887Z",
     
    5252        assert.equal(commit['authorName'], submitted['author']['name']);
    5353        assert.equal(commit['authorEmail'], submitted['author']['account']);
     54        if(submitted['previousCommit']) {
     55            assert.ok(commit['previousCommit']);
     56        } else {
     57            assert.equal(commit['previousCommit'], null);
     58        }
    5459    }
    5560
     
    8994                assertCommitIsSameAsOneSubmitted(commits[1], submittedCommits[1]);
    9095                assertCommitIsSameAsOneSubmitted(commits[2], submittedCommits[2]);
    91             });
    92         });       
     96                assert.equal(commits[2]['previousCommit'], commits[1]['id']);
     97            });
     98        });
    9399    });
    94100
     
    231237                assert.equal(result['commits'].length, 1);
    232238                assertCommitIsSameAsOneSubmitted(result['commits'][0], {
    233                     parent: null,
     239                    previousCommit: null,
    234240                    revision: '210950',
    235241                    time: '2017-01-20T03:49:37.887Z',
     
    300306                assert.deepEqual(result['commits'].length, 2);
    301307                assertCommitIsSameAsOneSubmitted(result['commits'][0], {
    302                     parent: null,
     308                    previousCommit: null,
    303309                    revision: '210949',
    304310                    time: '2017-01-20T03:23:50.645Z',
     
    307313                });
    308314                assertCommitIsSameAsOneSubmitted(result['commits'][1], {
    309                     parent: null,
     315                    previousCommit: null,
    310316                    revision: '210950',
    311317                    time: '2017-01-20T03:49:37.887Z',
  • trunk/Websites/perf.webkit.org/server-tests/api-report-commits-tests.js

    r201718 r212947  
    5555            {
    5656                "repository": "WebKit",
    57                 "parent": "141977",
     57                "previousCommit": "141977",
    5858                "revision": "141978",
    5959                "time": "2013-02-06T09:54:56.0Z",
    6060                "author": {"name": "Mikhail Pozdnyakov", "account": "mikhail.pozdnyakov@intel.com"},
    6161                "message": "another message",
     62            }
     63        ]
     64    };
     65
     66    const subversionInvalidPreviousCommit = {
     67        "slaveName": "someSlave",
     68        "slavePassword": "somePassword",
     69        "commits": [
     70            {
     71                "repository": "WebKit",
     72                "previousCommit": "99999",
     73                "revision": "12345",
     74                "time": "2013-02-06T08:55:20.9Z",
     75                "author": {"name": "Commit Queue", "account": "commit-queue@webkit.org"},
     76                "message": "some message",
    6277            }
    6378        ]
     
    159174            assert.equal(commits[0]['message'], reportedData['message']);
    160175            assert.equal(commits[0]['committer'], committers[0]['id']);
     176            assert.equal(commits[0]['previous_commit'], null);
    161177            assert.equal(committers[0]['name'], reportedData['author']['name']);
    162178            assert.equal(committers[0]['account'], reportedData['author']['account']);
     
    167183            assert.equal(commits[1]['message'], reportedData['message']);
    168184            assert.equal(commits[1]['committer'], committers[1]['id']);
     185            assert.equal(commits[1]['previous_commit'], commits[0]['id']);
    169186            assert.equal(committers[1]['name'], reportedData['author']['name']);
    170187            assert.equal(committers[1]['account'], reportedData['author']['account']);
    171188
     189            done();
     190        }).catch(done);
     191    });
     192
     193    it("should fail if previous commit is invalid", function (done) {
     194        const db = TestServer.database();
     195        addSlaveForReport(subversionInvalidPreviousCommit).then(function () {
     196            return TestServer.remoteAPI().postJSON('/api/report-commits/', subversionInvalidPreviousCommit);
     197        }).then(function (response) {
     198            assert.equal(response['status'], 'FailedToFindPreviousCommit');
     199            return db.selectAll('commits');
     200        }).then(function (result) {
     201            assert.equal(result.length, 0);
    172202            done();
    173203        }).catch(done);
     
    228258            assert.equal(committers[0]['name'], firstData['author']['name']);
    229259            assert.equal(committers[0]['account'], firstData['author']['account']);
    230            
     260
    231261            assert.equal(commits[1]['id'], 3);
    232262            assert.equal(commits[1]['message'], null);
  • trunk/Websites/perf.webkit.org/tools/sync-commits.py

    r210982 r212947  
    2424    parser.add_argument('--seconds-to-sleep', type=float, default=900, help='The seconds to sleep between iterations')
    2525    parser.add_argument('--max-fetch-count', type=int, default=10, help='The number of commits to fetch at once')
    26     parser.add_argument('--max-ancestor-fetch-count', type=int, default=100, help='The number of commits to fetch at once if some commits are missing parents')
     26    parser.add_argument('--max-ancestor-fetch-count', type=int, default=100, help='The number of commits to fetch at once if some commits are missing previous commits')
    2727    args = parser.parse_args()
    2828
     
    8080
    8181            result = submit_commits(pending_commits, server_config['server']['url'],
    82                 server_config['slave']['name'], server_config['slave']['password'], ['OK', 'FailedToFindParentCommit'])
     82                server_config['slave']['name'], server_config['slave']['password'], ['OK', 'FailedToFindPreviousCommit'])
    8383
    8484            if result.get('status') == 'OK':
    8585                break
    8686
    87             if result.get('status') == 'FailedToFindParentCommit':
    88                 parent_commit = self.fetch_commit(server_config, result['commit']['parent'])
    89                 if not parent_commit:
    90                     raise Exception('Could not find the parent %s of %s' % (result['commit']['parent'], result['commit']['revision']))
    91                 pending_commits = [parent_commit] + pending_commits
     87            if result.get('status') == 'FailedToFindPreviousCommit':
     88                previous_commit = self.fetch_commit(server_config, result['commit']['previousCommit'])
     89                if not previous_commit:
     90                    raise Exception('Could not find the previous commit %s of %s' % (result['commit']['previousCommit'], result['commit']['revision']))
     91                pending_commits = [previous_commit] + pending_commits
    9292
    9393        if result.get('status') != 'OK':
     
    224224        commit_time = int(tokens[1])
    225225        author_email = tokens[2]
    226         parent_hash = tokens[3] if len(tokens) >= 4 else None
     226        previous_hash = tokens[3] if len(tokens) >= 4 else None
    227227
    228228        author_name = self._run_git_command(['log', current_hash, '-1', '--pretty=%cn'])
     
    232232            'repository': self._name,
    233233            'revision': current_hash,
    234             'parent': parent_hash,
     234            'previousCommit': previous_hash,
    235235            'time': datetime.fromtimestamp(commit_time).strftime(r'%Y-%m-%dT%H:%M:%S.%f'),
    236236            'author': {'account': author_email, 'name': author_name},
  • trunk/Websites/perf.webkit.org/unit-tests/analysis-task-tests.js

    r204189 r212947  
    4444                'message': 'Commit message',
    4545                'order': null,
    46                 'parent': null,
     46                'previousCommit': null,
    4747                'repository': '11',
    4848                'revision': '196051',
Note: See TracChangeset for help on using the changeset viewer.