Title: [201123] trunk/Websites/perf.webkit.org
Revision
201123
Author
rn...@webkit.org
Date
2016-05-18 19:39:54 -0700 (Wed, 18 May 2016)

Log Message

Analysis task should look for a git commit based on abridged hashes
https://bugs.webkit.org/show_bug.cgi?id=157877
<rdar://problem/26254374>

Reviewed by Chris Dumez.

Made /privileged-api/associate-commit look for commits using LIKE instead of an exact match.
Associate the commit when there is exactly one match.

* public/include/commit-log-fetcher.php:
(CommitLogFetcher::fetch_between):
* public/include/db.php:
(Database::escape_for_like): Extracted from CommitLogFetcher::fetch_between.
* public/privileged-api/associate-commit.php:
(main): Look for the commits using LIKE. Reject whenever there are multiple commits. We limit the number of
matches to two for performance when the user specifies something that almost thousands of commits: e.g. "1".
* public/v3/pages/analysis-task-page.js:
(AnalysisTaskPage.prototype._associateCommit): Added human friendly error messages for mismatching commits.

Modified Paths

Diff

Modified: trunk/Websites/perf.webkit.org/ChangeLog (201122 => 201123)


--- trunk/Websites/perf.webkit.org/ChangeLog	2016-05-19 01:27:49 UTC (rev 201122)
+++ trunk/Websites/perf.webkit.org/ChangeLog	2016-05-19 02:39:54 UTC (rev 201123)
@@ -1,5 +1,26 @@
 2016-05-18  Ryosuke Niwa  <rn...@webkit.org>
 
+        Analysis task should look for a git commit based on abridged hashes
+        https://bugs.webkit.org/show_bug.cgi?id=157877
+        <rdar://problem/26254374>
+
+        Reviewed by Chris Dumez.
+
+        Made /privileged-api/associate-commit look for commits using LIKE instead of an exact match.
+        Associate the commit when there is exactly one match.
+
+        * public/include/commit-log-fetcher.php:
+        (CommitLogFetcher::fetch_between):
+        * public/include/db.php:
+        (Database::escape_for_like): Extracted from CommitLogFetcher::fetch_between.
+        * public/privileged-api/associate-commit.php:
+        (main): Look for the commits using LIKE. Reject whenever there are multiple commits. We limit the number of
+        matches to two for performance when the user specifies something that almost thousands of commits: e.g. "1".
+        * public/v3/pages/analysis-task-page.js:
+        (AnalysisTaskPage.prototype._associateCommit): Added human friendly error messages for mismatching commits.
+
+2016-05-18  Ryosuke Niwa  <rn...@webkit.org>
+
         Unreviewed build fix. Use --date-order so that every child commit appears after its parent.
         Otherwise we'll hit a FailedToFindParentCommit error while submitting a commit that appears before its parent.
 

Modified: trunk/Websites/perf.webkit.org/public/include/commit-log-fetcher.php (201122 => 201123)


--- trunk/Websites/perf.webkit.org/public/include/commit-log-fetcher.php	2016-05-19 01:27:49 UTC (rev 201122)
+++ trunk/Websites/perf.webkit.org/public/include/commit-log-fetcher.php	2016-05-19 02:39:54 UTC (rev 201123)
@@ -65,7 +65,7 @@
         }
 
         if ($keyword) {
-            array_push($values, '%' . str_replace(array('\\', '_', '%'), array('\\\\', '\\_', '\\%'), $keyword) . '%');
+            array_push($values, '%' . Database::escape_for_like($keyword) . '%');
             $keyword_index = '$' . count($values);
             array_push($values, ltrim($keyword, 'r'));
             $revision_index = '$' . count($values);

Modified: trunk/Websites/perf.webkit.org/public/include/db.php (201122 => 201123)


--- trunk/Websites/perf.webkit.org/public/include/db.php	2016-05-19 01:27:49 UTC (rev 201122)
+++ trunk/Websites/perf.webkit.org/public/include/db.php	2016-05-19 02:39:54 UTC (rev 201123)
@@ -84,6 +84,10 @@
         return intval($timestamp_in_s * 1000);
     }
 
+    static function escape_for_like($string) {
+        return str_replace(array('\\', '_', '%'), array('\\\\', '\\_', '\\%'), $string);
+    }
+
     function connect() {
         $databaseConfig = config('database');
         $this->connection = @pg_connect('host=' . $databaseConfig['host'] . ' port=' . $databaseConfig['port']

Modified: trunk/Websites/perf.webkit.org/public/privileged-api/associate-commit.php (201122 => 201123)


--- trunk/Websites/perf.webkit.org/public/privileged-api/associate-commit.php	2016-05-19 01:27:49 UTC (rev 201122)
+++ trunk/Websites/perf.webkit.org/public/privileged-api/associate-commit.php	2016-05-19 02:39:54 UTC (rev 201123)
@@ -29,13 +29,18 @@
         require_format('Kind', $kind, '/^(cause|fix)$/');
 
         $commit_info = array('repository' => $repository_id, 'revision' => $revision);
-        $commit_row = $db->select_first_row('commits', 'commit', $commit_info);
-        if (!$commit_row) {
+        $commit_rows = $db->query_and_fetch_all('SELECT commit_id FROM commits WHERE commit_repository = $1 AND commit_revision LIKE $2 LIMIT 2',
+            array($repository_id, '%' . Database::escape_for_like($revision) . '%'));
+        if (count($commit_rows) > 1) {
             $db->rollback_transaction();
+            exit_with_error('AmbiguousRevision', $commit_info);            
+        } else if (!$commit_rows) {
+            $db->rollback_transaction();
             exit_with_error('CommitNotFound', $commit_info);
         }
-        $commit_id = $commit_row['commit_id'];
 
+        $commit_id = $commit_rows[0]['commit_id'];
+
         $association = array('task' => $analysis_task_id, 'commit' => $commit_id, 'is_fix' => Database::to_database_boolean($kind == 'fix'));
         $commit_id = $db->update_or_insert_row('task_commits', 'taskcommit',
             array('task' => $analysis_task_id, 'commit' => $commit_id), $association, 'commit');

Modified: trunk/Websites/perf.webkit.org/public/v3/pages/analysis-task-page.js (201122 => 201123)


--- trunk/Websites/perf.webkit.org/public/v3/pages/analysis-task-page.js	2016-05-19 01:27:49 UTC (rev 201122)
+++ trunk/Websites/perf.webkit.org/public/v3/pages/analysis-task-page.js	2016-05-19 02:39:54 UTC (rev 201123)
@@ -496,7 +496,12 @@
         var render = this.render.bind(this);
         return this._task.associateCommit(kind, repository, revision).then(render, function (error) {
             render();
-            alert('Failed to associate the commit: ' + error);
+            if (error == 'AmbiguousRevision')
+                alert('There are multiple revisions that match the specified string: ' + revision);
+            else if (error == 'CommitNotFound')
+                alert('There are no revisions that match the specified string:' + revision);
+            else
+                alert('Failed to associate the commit: ' + error);
         });
     }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to