Changeset 172892 in webkit


Ignore:
Timestamp:
Aug 23, 2014 6:35:16 PM (10 years ago)
Author:
ap@apple.com
Message:

build.webkit.org/dashboard: Further improve Trac loading
https://bugs.webkit.org/show_bug.cgi?id=136174

Reviewed by Timothy Hatcher.

  • BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js:

(Trac.prototype._xmlTimelineURL): Passing -1 as "max" resulted in an off by one
error, the oldest commit within the range wasn't returned. The correct argument for
"no limit" is 0.
(Trac.prototype.load): Added a function to load a specific time range.
(Trac.prototype._loaded): Updated to support loading revisions that are arbitrarily
positioned with regards to ones that were already known.

Location:
trunk/Tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js

    r172747 r172892  
    11/*
    2  * Copyright (C) 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013, 2014 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4545
    4646Trac.Event = {
    47     CommitsUpdated: "commits-updated"
     47    CommitsUpdated: "commits-updated",
     48    Loaded: "loaded"
    4849};
    4950
     
    7980        var toDay = new Date(toDate.getFullYear(), toDate.getMonth(), toDate.getDate());
    8081
    81         return this.baseURL + "timeline?changeset=on&format=rss&max=-1" +
     82        return this.baseURL + "timeline?changeset=on&format=rss&max=0" +
    8283            "&from=" +  (toDay.getMonth() + 1) + "%2F" + toDay.getDate() + "%2F" + (toDay.getFullYear() % 100) +
    8384            "&daysback=" + ((toDay - fromDay) / 1000 / 60 / 60 / 24);
     
    127128    _loaded: function(dataDocument)
    128129    {
    129         var earliestKnownRevision = 0;
    130         var latestKnownRevision = 0;
    131         if (this.recordedCommits.length) {
    132             earliestKnownRevision = this.recordedCommits[0].revisionNumber;
    133             latestKnownRevision = this.recordedCommits[this.recordedCommits.length - 1].revisionNumber;
    134         }
     130        var recordedRevisionNumbers = this.recordedCommits.reduce(function(previousResult, commit) {
     131            previousResult[commit.revisionNumber] = commit;
     132            return previousResult;
     133        }, {});
    135134
    136135        var knownCommitsWereUpdated = false;
    137136        var newCommits = [];
    138         var newCommitsBeforeEarliestKnownRevision = [];
    139137
    140138        var commitInfoElements = dataDocument.evaluate("/rss/channel/item", dataDocument, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE);
    141         var commitInfoElement = undefined;
    142         var indexInRecordedCommits = undefined;
     139        var commitInfoElement;
    143140        while (commitInfoElement = commitInfoElements.iterateNext()) {
    144141            var commit = this._convertCommitInfoElementToObject(dataDocument, commitInfoElement);
    145             if (commit.revisionNumber > latestKnownRevision) {
    146                 console.assert(typeof indexInRecordedCommits === "undefined");
    147                 newCommits.push(commit);
    148             } else if (commit.revisionNumber < earliestKnownRevision) {
    149                 console.assert(typeof indexInRecordedCommits === "undefined" || indexInRecordedCommits === -1);
    150                 newCommitsBeforeEarliestKnownRevision.push(commit);
    151             } else {
    152                 if (typeof indexInRecordedCommits === "undefined") {
    153                     // We could have started anywhere in the recorded commits array, let's find where.
    154                     // With periodic updates, this will be the latest recorded commit, so starting from the end.
    155                     for (var i = this.recordedCommits.length - 1; i >= 0; --i) {
    156                         if (this.recordedCommits[i].revisionNumber === commit.revisionNumber) {
    157                             indexInRecordedCommits = i;
    158                             break;
    159                         }
    160                     }
    161                 }
    162 
    163                 console.assert(indexInRecordedCommits >= 0);
    164                 console.assert(this.recordedCommits[indexInRecordedCommits].revisionNumber === commit.revisionNumber);
    165 
     142            if (commit.revisionNumber in recordedRevisionNumbers) {
    166143                // Author could have changed, as commit queue replaces it after the fact.
    167                 if (this.recordedCommits[indexInRecordedCommits].author !== commit.author) {
    168                     this.recordedCommits[indexInRecordedCommits].author = commit.author;
     144                console.assert(recordedRevisionNumbers[commit.revisionNumber].revisionNumber === commit.revisionNumber);
     145                if (recordedRevisionNumbers[commit.revisionNumber].author != commit.author) {
     146                    recordedRevisionNumbers[commit.revisionNumber].author = commit.author;
    169147                    knownCommitWasUpdated = true;
    170148                }
    171                 --indexInRecordedCommits;
    172             }
     149            } else
     150                newCommits.push(commit);
    173151        }
    174152
    175         if (newCommits.length || newCommitsBeforeEarliestKnownRevision.length)
    176             this.recordedCommits = newCommitsBeforeEarliestKnownRevision.reverse().concat(this.recordedCommits, newCommits.reverse());
     153        if (newCommits.length)
     154            this.recordedCommits = newCommits.concat(this.recordedCommits).sort(function(a, b) { return a.revisionNumber - b.revisionNumber; });
    177155
    178         if (newCommits.length || newCommitsBeforeEarliestKnownRevision.length || knownCommitsWereUpdated)
     156        if (newCommits.length || knownCommitsWereUpdated)
    179157            this.dispatchEventToListeners(Trac.Event.CommitsUpdated, null);
     158    },
     159
     160    load: function(fromDate, toDate)
     161    {
     162        loadXML(this._xmlTimelineURL(fromDate, toDate), function(dataDocument) {
     163            this._loaded(dataDocument);
     164            this.dispatchEventToListeners(Trac.Event.Loaded, [fromDate, toDate]);
     165        }.bind(this), this._needsAuthentication ? { withCredentials: true } : {});
    180166    },
    181167
  • trunk/Tools/ChangeLog

    r172891 r172892  
     12014-08-23  Alexey Proskuryakov  <ap@apple.com>
     2
     3        build.webkit.org/dashboard: Further improve Trac loading
     4        https://bugs.webkit.org/show_bug.cgi?id=136174
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        * BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js:
     9        (Trac.prototype._xmlTimelineURL): Passing -1 as "max" resulted in an off by one
     10        error, the oldest commit within the range wasn't returned. The correct argument for
     11        "no limit" is 0.
     12        (Trac.prototype.load): Added a function to load a specific time range.
     13        (Trac.prototype._loaded): Updated to support loading revisions that are arbitrarily
     14        positioned with regards to ones that were already known.
     15
    1162014-08-23  Alexey Proskuryakov  <ap@apple.com>
    217
Note: See TracChangeset for help on using the changeset viewer.