build.webkit.org/dashboard should filter out commits to other branches
authorap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Feb 2015 17:42:36 +0000 (17:42 +0000)
committerap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Feb 2015 17:42:36 +0000 (17:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=140362

Reviewed by Tim Horton.

* BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotQueue.js:
(BuildbotQueue):
* BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotQueueView.js:
(BuildbotQueueView.prototype._presentPopoverForPendingCommits):
(BuildbotQueueView.prototype._presentPopoverForRevisionRange):
(BuildbotQueueView.prototype._revisionContentWithPopoverForIteration):
(BuildbotQueueView.prototype.revisionContentForIteration):
(BuildbotQueueView.prototype._appendPendingRevisionCount): Deleted.
(BuildbotQueueView.prototype._popoverLinesForCommitRange): Deleted.
(BuildbotQueueView.prototype._revisionPopoverContentForIteration): Deleted.
* BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js:
(Trac.prototype.get oldestRecordedRevisionNumber):
(Trac.prototype.commitsOnBranch):
(Trac.prototype._xmlTimelineURL):
(Trac.prototype._convertCommitInfoElementToObject):
(Trac.prototype._update):
(Trac.prototype.startPeriodicUpdates):
(Trac.prototype.loadMoreHistoricalData):
(Trac.prototype.update): Deleted.

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

Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotQueue.js
Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotQueueView.js
Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js
Tools/ChangeLog

index 72d305e..f66c7b6 100644 (file)
@@ -33,7 +33,7 @@ BuildbotQueue = function(buildbot, id, info)
     this.buildbot = buildbot;
     this.id = id;
 
-    this.branch = info.branch || null;
+    this.branch = info.branch || { openSource: "trunk", internal: "trunk" };
     this.platform = info.platform.name || "unknown";
     this.debug = info.debug || false;
     this.builder = info.builder || false;
index c38c716..b66c749 100644 (file)
@@ -87,21 +87,23 @@ BuildbotQueueView.prototype = {
             return;
 
         var latestRecordedOpenSourceRevisionNumber = webkitTrac.latestRecordedRevisionNumber;
-        if (!latestRecordedOpenSourceRevisionNumber)
+        if (!latestRecordedOpenSourceRevisionNumber || webkitTrac.oldestRecordedRevisionNumber > latestProductiveIteration.openSourceRevision) {
+            webkitTrac.loadMoreHistoricalData();
             return;
+        }
 
-        var totalRevisionsBehind = latestRecordedOpenSourceRevisionNumber - latestProductiveIteration.openSourceRevision;
-        if (totalRevisionsBehind < 0)
-            totalRevisionsBehind = 0;
+        // FIXME: To be 100% correct, we should also filter out changes that are ignored by
+        // the queue, see _should_file_trigger_build in wkbuild.py.
+        var totalRevisionsBehind = webkitTrac.commitsOnBranch(queue.branch.openSource, function(commit) { return commit.revisionNumber > latestProductiveIteration.openSourceRevision; }).length;
 
         if (latestProductiveIteration.internalRevision) {
             var latestRecordedInternalRevisionNumber = internalTrac.latestRecordedRevisionNumber;
-            if (!latestRecordedInternalRevisionNumber)
+            if (!latestRecordedInternalRevisionNumber || internalTrac.oldestRecordedRevisionNumber > latestProductiveIteration.internalRevision) {
+                internalTrac.loadMoreHistoricalData();
                 return;
+            }
 
-            var internalRevisionsBehind = latestRecordedInternalRevisionNumber - latestProductiveIteration.internalRevision;
-            if (internalRevisionsBehind > 0)
-                totalRevisionsBehind += internalRevisionsBehind;
+            totalRevisionsBehind += internalTrac.commitsOnBranch(queue.branch.internal, function(commit) { return commit.revisionNumber > latestProductiveIteration.internalRevision; }).length;
         }
 
         if (!totalRevisionsBehind)
@@ -115,7 +117,7 @@ BuildbotQueueView.prototype = {
         new PopoverTracker(messageElement, this._presentPopoverForPendingCommits.bind(this), queue);
     },
 
-    _popoverLinesForCommitRange: function(trac, firstRevisionNumber, lastRevisionNumber)
+    _popoverLinesForCommitRange: function(trac, branch, firstRevisionNumber, lastRevisionNumber)
     {
         function lineForCommit(trac, commit)
         {
@@ -142,22 +144,14 @@ BuildbotQueueView.prototype = {
             return result;
         }
 
-        // This function only adds lines about commits that the trac object knows about.
-        // Alternatively, it could add links without info and/or trigger loading additional
-        // data, but this probably doesn't matter for Dashboard use.
-        var result = [];
-        for (var i = trac.recordedCommits.length - 1; i >= 0; --i) {
-            var commit = trac.recordedCommits[i];
-            if (commit.revisionNumber > lastRevisionNumber)
-                continue;
-
-            if (commit.revisionNumber < firstRevisionNumber)
-                break;
-
-            result.push(lineForCommit(trac, commit));
-        }
+        console.assert(trac.oldestRecordedRevisionNumber >= firstRevisionNumber);
 
-        return result;
+        // FIXME: To be 100% correct, we should also filter out changes that are ignored by
+        // the queue, see _should_file_trigger_build in wkbuild.py.
+        var commits = trac.commitsOnBranch(branch, function(commit) { return commit.revisionNumber >= firstRevisionNumber && commit.revisionNumber <= lastRevisionNumber; });
+        return commits.map(function(commit) {
+            return lineForCommit(trac, commit);
+        }, this).reverse();
     },
 
     _presentPopoverForPendingCommits: function(element, popover, queue)
@@ -169,13 +163,13 @@ BuildbotQueueView.prototype = {
         var content = document.createElement("div");
         content.className = "commit-history-popover";
 
-        var linesForOpenSource = this._popoverLinesForCommitRange(webkitTrac, latestProductiveIteration.openSourceRevision + 1, webkitTrac.latestRecordedRevisionNumber);
+        var linesForOpenSource = this._popoverLinesForCommitRange(webkitTrac, queue.branch.openSource, latestProductiveIteration.openSourceRevision + 1, webkitTrac.latestRecordedRevisionNumber);
         for (var i = 0; i != linesForOpenSource.length; ++i)
             content.appendChild(linesForOpenSource[i]);
 
         var linesForInternal = [];
         if (latestProductiveIteration.internalRevision && internalTrac.latestRecordedRevisionNumber)
-            var linesForInternal = this._popoverLinesForCommitRange(internalTrac, latestProductiveIteration.internalRevision + 1, internalTrac.latestRecordedRevisionNumber);
+            var linesForInternal = this._popoverLinesForCommitRange(internalTrac, queue.branch.internal, latestProductiveIteration.internalRevision + 1, internalTrac.latestRecordedRevisionNumber);
 
         if (linesForOpenSource.length && linesForInternal.length)
             this._addDividerToPopover(content);
@@ -195,7 +189,8 @@ BuildbotQueueView.prototype = {
         var content = document.createElement("div");
         content.className = "commit-history-popover";
 
-        var linesForCommits = this._popoverLinesForCommitRange(context.trac, context.firstRevision, context.lastRevision);
+        // FIXME: Nothing guarantees that Trac has historical data for these revisions.
+        var linesForCommits = this._popoverLinesForCommitRange(context.trac, context.branch, context.firstRevision, context.lastRevision);
         if (!linesForCommits.length)
             return false;
 
@@ -215,7 +210,7 @@ BuildbotQueueView.prototype = {
         return true;
     },
 
-    _revisionPopoverContentForIteration: function(iteration, previousIteration, internal)
+    _revisionContentWithPopoverForIteration: function(iteration, previousIteration, internal)
     {
         var content = document.createElement("span");
         content.textContent = "r" + (internal ? iteration.internalRevision : iteration.openSourceRevision);
@@ -224,6 +219,7 @@ BuildbotQueueView.prototype = {
         if (previousIteration) {
             var context = {
                 trac: internal ? internalTrac : webkitTrac,
+                branch: internal ? iteration.queue.branch.internal : iteration.queue.branch.openSource,
                 firstRevision: (internal ? previousIteration.internalRevision : previousIteration.openSourceRevision) + 1,
                 lastRevision: internal ? iteration.internalRevision : iteration.openSourceRevision
             };
@@ -272,12 +268,12 @@ BuildbotQueueView.prototype = {
     {
         console.assert(iteration.openSourceRevision);
 
-        var openSourceContent = this._revisionPopoverContentForIteration(iteration, previousDisplayedIteration);
+        var openSourceContent = this._revisionContentWithPopoverForIteration(iteration, previousDisplayedIteration);
 
         if (!iteration.internalRevision)
             return openSourceContent;
 
-        var internalContent = this._revisionPopoverContentForIteration(iteration, previousDisplayedIteration, true);
+        var internalContent = this._revisionContentWithPopoverForIteration(iteration, previousDisplayedIteration, true);
 
         var fragment = document.createDocumentFragment();
         fragment.appendChild(openSourceContent);
index 24bd5cc..8321668 100644 (file)
@@ -49,6 +49,13 @@ Trac.prototype = {
     constructor: Trac,
     __proto__: BaseObject.prototype,
 
+    get oldestRecordedRevisionNumber()
+    {
+        if (!this.recordedCommits.length)
+            return undefined;
+        return this.recordedCommits[0].revisionNumber;
+    },
+
     get latestRecordedRevisionNumber()
     {
         if (!this.recordedCommits.length)
@@ -56,6 +63,13 @@ Trac.prototype = {
         return this.recordedCommits[this.recordedCommits.length - 1].revisionNumber;
     },
 
+    commitsOnBranch: function(branch, filter)
+    {
+        return this.recordedCommits.filter(function(commit) {
+            return (!commit.containsBranchLocation || commit.branch === branch) && filter(commit);
+        });
+    },
+
     revisionURL: function(revision)
     {
         return this.baseURL + "changeset/" + encodeURIComponent(revision);
@@ -63,14 +77,6 @@ Trac.prototype = {
 
     _xmlTimelineURL: function(fromDate, toDate)
     {
-        if (typeof fromDate === "undefined") {
-            fromDate = new Date();
-            toDate = new Date(fromDate);
-            // By default, get at least one full day of changesets, as the current day may have only begun.
-            fromDate.setDate(fromDate.getDate() - 1);
-        } else if (typeof toDate === "undefined")
-            toDate = fromDate;
-
         console.assert(fromDate <= toDate);
 
         var fromDay = new Date(fromDate.getFullYear(), fromDate.getMonth(), fromDate.getDate());
@@ -144,8 +150,9 @@ Trac.prototype = {
             else if (location.startsWith("submissions/"))
                 ; // These changes are never relevant to the dashboard.
             else {
+                // result.containsBranchLocation remains true, because this commit does
+                // not match any explicitly specified branches.
                 console.assert(false);
-                result.containsBranchLocation = false;
             }
         }
 
@@ -195,14 +202,52 @@ Trac.prototype = {
         }.bind(this), this._needsAuthentication ? { withCredentials: true } : {});
     },
 
-    update: function()
+    _update: function()
     {
-        loadXML(this._xmlTimelineURL(), this._loaded.bind(this), this._needsAuthentication ? { withCredentials: true } : {});
+        var fromDate = new Date(this._latestLoadedDate);
+        var toDate = new Date();
+
+        this._latestLoadedDate = toDate;
+
+        loadXML(this._xmlTimelineURL(fromDate, toDate), this._loaded.bind(this), this._needsAuthentication ? { withCredentials: true } : {});
     },
 
     startPeriodicUpdates: function()
     {
-        this.update();
-        this.updateTimer = setInterval(this.update.bind(this), Trac.UpdateInterval);
-    }
+        console.assert(!this._oldestHistoricalDate);
+
+        var today = new Date();
+
+        this._oldestHistoricalDate = today;
+        this._latestLoadedDate = today;
+
+        this._loadingHistoricalData = true;
+        loadXML(this._xmlTimelineURL(today, today), function(dataDocument) {
+            this._loadingHistoricalData = false;
+            this._loaded(dataDocument);
+        }.bind(this), this._needsAuthentication ? { withCredentials: true } : {});
+
+        this.updateTimer = setInterval(this._update.bind(this), Trac.UpdateInterval);
+    },
+
+    loadMoreHistoricalData: function()
+    {
+        console.assert(this._oldestHistoricalDate);
+
+        if (this._loadingHistoricalData)
+            return;
+
+        // Load one more day of historical data.
+        var fromDate = new Date(this._oldestHistoricalDate);
+        fromDate.setDate(fromDate.getDate() - 1);
+        var toDate = new Date(fromDate);
+
+        this._oldestHistoricalDate = fromDate;
+
+        this._loadingHistoricalData = true;
+        loadXML(this._xmlTimelineURL(fromDate, toDate), function(dataDocument) {
+            this._loadingHistoricalData = false;
+            this._loaded(dataDocument);
+        }.bind(this), this._needsAuthentication ? { withCredentials: true } : {});
+    },
 };
index 3d83a99..1f797fc 100644 (file)
@@ -1,3 +1,30 @@
+2015-02-23  Alexey Proskuryakov  <ap@apple.com>
+
+        build.webkit.org/dashboard should filter out commits to other branches
+        https://bugs.webkit.org/show_bug.cgi?id=140362
+
+        Reviewed by Tim Horton.
+
+        * BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotQueue.js:
+        (BuildbotQueue):
+        * BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotQueueView.js:
+        (BuildbotQueueView.prototype._presentPopoverForPendingCommits):
+        (BuildbotQueueView.prototype._presentPopoverForRevisionRange):
+        (BuildbotQueueView.prototype._revisionContentWithPopoverForIteration):
+        (BuildbotQueueView.prototype.revisionContentForIteration):
+        (BuildbotQueueView.prototype._appendPendingRevisionCount): Deleted.
+        (BuildbotQueueView.prototype._popoverLinesForCommitRange): Deleted.
+        (BuildbotQueueView.prototype._revisionPopoverContentForIteration): Deleted.
+        * BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js:
+        (Trac.prototype.get oldestRecordedRevisionNumber):
+        (Trac.prototype.commitsOnBranch):
+        (Trac.prototype._xmlTimelineURL):
+        (Trac.prototype._convertCommitInfoElementToObject):
+        (Trac.prototype._update):
+        (Trac.prototype.startPeriodicUpdates):
+        (Trac.prototype.loadMoreHistoricalData):
+        (Trac.prototype.update): Deleted.
+
 2015-02-21  Youenn Fablet  <youenn.fablet@crf.canon.fr>
 
         Tests don't work on some bots: Failed to stop wptwk