OwnedCommitViewer should include the preceding commit.
authordewei_zhu@apple.com <dewei_zhu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Oct 2017 09:44:39 +0000 (09:44 +0000)
committerdewei_zhu@apple.com <dewei_zhu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Oct 2017 09:44:39 +0000 (09:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=179047

Reviewed by Ryosuke Niwa.

OwnedCommitViewer shows the difference between owned commits.
To show changes made by first owned commit, we need to have the preceding commit information.

* public/v3/components/commit-log-viewer.js:
(CommitLogViewer):
(CommitLogViewer.prototype._fetchCommitLogs): Fetch preceding commit if the commits fetched is not a single commit.
(CommitLogViewer.prototype.render):
(CommitLogViewer.prototype._renderCommitList): Conditionally rendering preceding commit in commit list.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224227 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Websites/perf.webkit.org/ChangeLog
Websites/perf.webkit.org/public/v3/components/commit-log-viewer.js

index dbd5f42..de57dff 100644 (file)
@@ -1,3 +1,19 @@
+2017-10-31  Dewei Zhu  <dewei_zhu@apple.com>
+
+        OwnedCommitViewer should include the preceding commit.
+        https://bugs.webkit.org/show_bug.cgi?id=179047
+
+        Reviewed by Ryosuke Niwa.
+
+        OwnedCommitViewer shows the difference between owned commits.
+        To show changes made by first owned commit, we need to have the preceding commit information.
+
+        * public/v3/components/commit-log-viewer.js:
+        (CommitLogViewer):
+        (CommitLogViewer.prototype._fetchCommitLogs): Fetch preceding commit if the commits fetched is not a single commit.
+        (CommitLogViewer.prototype.render):
+        (CommitLogViewer.prototype._renderCommitList): Conditionally rendering preceding commit in commit list.
+
 2017-10-24  Dewei Zhu  <dewei_zhu@apple.com>
 
         Fix a bug in syncing script that test/build syncer is never set.
index a6e6cc2..cc20c26 100644 (file)
@@ -8,6 +8,7 @@ class CommitLogViewer extends ComponentBase {
         this._repository = null;
         this._fetchingPromise = null;
         this._commits = null;
+        this._precedingCommit = null;
         this._renderCommitListLazily = new LazilyEvaluatedFunction(this._renderCommitList.bind(this));
         this._showRepositoryName = true;
     }
@@ -35,7 +36,8 @@ class CommitLogViewer extends ComponentBase {
         }
 
         let promise;
-        if (!precedingRevision || precedingRevision == lastRevision)
+        const fetchSingleCommit = !precedingRevision || precedingRevision == lastRevision;
+        if (fetchSingleCommit)
             promise = CommitLog.fetchForSingleRevision(repository, lastRevision);
         else
             promise = CommitLog.fetchBetweenRevisions(repository, precedingRevision, lastRevision);
@@ -46,9 +48,26 @@ class CommitLogViewer extends ComponentBase {
         this._fetchingPromise.then((commits) => {
             if (this._fetchingPromise != promise)
                 return;
-            this._fetchingPromise = null;
             this._commits = commits;
-            this.enqueueToRender();
+            if (fetchSingleCommit) {
+                this._fetchingPromise = null;
+                this._precedingCommit = null;
+                this.enqueueToRender();
+                return;
+            }
+            return CommitLog.fetchForSingleRevision(repository, precedingRevision).then((precedingCommit) => {
+                if (this._fetchingPromise != promise)
+                    return;
+                this._fetchingPromise = null;
+                this._precedingCommit = precedingCommit[0];
+                this.enqueueToRender();
+            }, (error) => {
+                if (this._fetchingPromise != promise)
+                    return;
+                this._fetchingPromise = null;
+                this._precedingCommit = null;
+                this.enqueueToRender();
+            });
         }, (error) => {
             if (this._fetchingPromise != promise)
                 return;
@@ -65,13 +84,14 @@ class CommitLogViewer extends ComponentBase {
         const shouldShowRepositoryName = this._repository && (this._commits || this._fetchingPromise) && this._showRepositoryName;
         this.content('repository-name').textContent = shouldShowRepositoryName ? this._repository.name() : '';
         this.content('spinner-container').style.display = this._fetchingPromise ? null : 'none';
-        this._renderCommitListLazily.evaluate(this._commits);
+        this._renderCommitListLazily.evaluate(this._commits, this._precedingCommit);
     }
 
-    _renderCommitList(commits)
+    _renderCommitList(commits, precedingCommit)
     {
         const element = ComponentBase.createElement;
         const link = ComponentBase.createLink;
+        commits = commits && precedingCommit && precedingCommit.ownsCommits() ? [precedingCommit].concat(commits) : commits;
         let previousCommit = null;
 
         this.renderReplace(this.content('commits-list'), (commits || []).map((commit) => {