Skip to content
Permalink
Browse files
Add support for Trac instances that host multiple projects.
https://bugs.webkit.org/show_bug.cgi?id=167524

Patch by Kocsen Chung <kocsen_chung@apple.com> on 2017-01-30
Reviewed by Alexey Proskuryakov.

When multiple projects are hosted on a single Trac instance, the current
behavior will retrieve changesets from all tracked projects.
This patch teaches Trac.js to get project-specific changesets from Trac.
We do this by replacing the parameter `changeset=on` to `repo-projectname=on`
when querying the Trac timeline.

To tell Trac to be aware of multi-project instances we leverage the
`options` parameter when creating a new instance:

    new Trac("https://mytrac.com/", { projectCanonical link: https://commits.webkit.org/"tracProjectName" });

If this option is not provided, the original behaviour will prevail.
Additionally, add corresponding tests.

* BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js:
(Trac): Reason about new optional parameter 'projectIdentifier'.
(Trac.prototype.revisionURL): Given a projectIdentifier, append it to the end of the URL.
(Trac.prototype._xmlTimelineURL): Given a projectIdentifier,
replace default parameter `changeset=on` with `repo-projectname=on`.
(Trac.prototype._convertCommitInfoElementToObject): Fix missing ';'.
* BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/resources/MockTrac.js:
(MockTrac): Add support for instantiating Trac with a projectIdentifier.
* BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/resources/tests.js:
(setup): Provide a multiple-project MockTrac instance to all test cases for testing.
Add the following tests:
    test("revisionURL")
    test("revisionURL with Trac Identifier")
    test("_xmlTimelineURL")
    test("_xmlTimelineURL with Trac Identifier")
(this.view._latestProductiveIteration): Fix missing ';'.

Canonical link: https://commits.webkit.org/184629@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@211388 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Kocsen Chung authored and webkit-commit-queue committed Jan 30, 2017
1 parent 964f1b9 commit 60143df722931ccbdbcfa9f8946a01b10848787d
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 10 deletions.
@@ -30,7 +30,11 @@ Trac = function(baseURL, options)
console.assert(baseURL);

this.baseURL = baseURL;
this._needsAuthentication = (typeof options === "object") && options[Trac.NeedsAuthentication] === true;
if (typeof options === "object") {
this._needsAuthentication = options[Trac.NeedsAuthentication] === true;
// We expect the projectIdentifier option iff the target Trac instance is hosting multiple repositories && Trac version > 1.0
this._projectName = options[Trac.ProjectIdentifier];
}

this.recordedCommits = []; // Will be sorted in ascending order.
};
@@ -40,6 +44,7 @@ BaseObject.addConstructorFunctions(Trac);
Trac.NO_MORE_REVISIONS = null;

Trac.NeedsAuthentication = "needsAuthentication";
Trac.ProjectIdentifier = "projectIdentifier";
Trac.UpdateInterval = 45000; // 45 seconds

Trac.Event = {
@@ -103,7 +108,10 @@ Trac.prototype = {

revisionURL: function(revision)
{
return this.baseURL + "changeset/" + encodeURIComponent(revision);
var url = this.baseURL + "changeset/" + encodeURIComponent(revision);
if (this._projectName)
url += '/' + encodeURIComponent(this._projectName);
return url;
},

_xmlTimelineURL: function(fromDate, toDate)
@@ -112,10 +120,14 @@ Trac.prototype = {

var fromDay = new Date(fromDate.getFullYear(), fromDate.getMonth(), fromDate.getDate());
var toDay = new Date(toDate.getFullYear(), toDate.getMonth(), toDate.getDate());

return this.baseURL + "timeline?changeset=on&format=rss&max=0" +
"&from=" + toDay.toISOString().slice(0, 10) +
"&daysback=" + ((toDay - fromDay) / 1000 / 60 / 60 / 24);
var changesetParameter = this._projectName ? "repo-" + this._projectName : "changeset";

return this.baseURL + "timeline?" +
changesetParameter + "=on" +
"&format=rss" +
"&max=0" +
"&from=" + encodeURIComponent(toDay.toISOString().slice(0, 10)) +
"&daysback=" + encodeURIComponent((toDay - fromDay) / 1000 / 60 / 60 / 24);
},

_parseRevisionFromURL: function(url)
@@ -150,7 +162,7 @@ Trac.prototype = {
var location = "";
if (parsedDescription.firstChild && parsedDescription.firstChild.className === "changes") {
// We can extract branch information when trac.ini contains "changeset_show_files=location".
location = doc.evaluate("//strong", parsedDescription.firstChild, null, XPathResult.STRING_TYPE).stringValue
location = doc.evaluate("//strong", parsedDescription.firstChild, null, XPathResult.STRING_TYPE).stringValue;
parsedDescription.removeChild(parsedDescription.firstChild);
}

@@ -23,9 +23,15 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/

MockTrac = function()
MockTrac = function(projectIdentifier)
{
Trac.call(this, "https://trac.webkit.org/");
if (projectIdentifier) {
var options = { };
options[Trac.ProjectIdentifier] = projectIdentifier;
Trac.call(this, "https://trac.webkit.org/", options);
} else {
Trac.call(this, "https://trac.webkit.org/");
}
};

BaseObject.addConstructorFunctions(MockTrac);
@@ -41,6 +41,7 @@ QUnit.done = function(details) {
module("Trac", {
setup: function() {
this.trac = new MockTrac();
this.tracWithIdentifier = new MockTrac("webkit");
}
});

@@ -121,6 +122,36 @@ test("commitsOnBranchInRevisionRange", function()
equal(commits.length, 2, "in range 33020, 33022");
});

test("revisionURL", function()
{
strictEqual(this.trac.revisionURL("33020"), "https://trac.webkit.org/changeset/33020", "changeset URL matches for 33020");
strictEqual(this.trac.revisionURL("0e498db5d8e5b5a342631"), "https://trac.webkit.org/changeset/0e498db5d8e5b5a342631", "changeset URL matches for 0e498db5d8e5b5a342631");
});

test("revisionURL with Trac Identifier", function()
{
strictEqual(this.tracWithIdentifier.revisionURL("33020"), "https://trac.webkit.org/changeset/33020/webkit", "changeset URL matches for 33020");
strictEqual(this.tracWithIdentifier.revisionURL("0e498db5d8e5b5a342631"), "https://trac.webkit.org/changeset/0e498db5d8e5b5a342631/webkit", "changeset URL matches for 0e498db5d8e5b5a342631");
});

test("_xmlTimelineURL", function()
{
var before = new Date("1/1/2017");
var after = new Date("1/2/2017");

strictEqual(this.trac._xmlTimelineURL(before, before), "https://trac.webkit.org/timeline?changeset=on&format=rss&max=0&from=2017-01-01&daysback=0");
strictEqual(this.trac._xmlTimelineURL(before, after), "https://trac.webkit.org/timeline?changeset=on&format=rss&max=0&from=2017-01-02&daysback=1");
});

test("_xmlTimelineURL with Trac Identifier", function()
{
var before = new Date("1/1/2017");
var after = new Date("1/2/2017");

strictEqual(this.tracWithIdentifier._xmlTimelineURL(before, before), "https://trac.webkit.org/timeline?repo-webkit=on&format=rss&max=0&from=2017-01-01&daysback=0");
strictEqual(this.tracWithIdentifier._xmlTimelineURL(before, after), "https://trac.webkit.org/timeline?repo-webkit=on&format=rss&max=0&from=2017-01-02&daysback=1");
});

module("BuildBotQueueView", {
setup: function() {
this.trac = new MockTrac();
@@ -179,7 +210,7 @@ test("_presentPopoverForPendingCommits no pending commits", function()
revision: { "openSource": "33021" },
};
return iteration;
}
};
var element = document.createElement("div");
var popover = new Dashboard.Popover();
this.view._presentPopoverForPendingCommits(element, popover, this.queue);
@@ -1,3 +1,41 @@
2017-01-30 Kocsen Chung <kocsen_chung@apple.com>

Add support for Trac instances that host multiple projects.
https://bugs.webkit.org/show_bug.cgi?id=167524

Reviewed by Alexey Proskuryakov.

When multiple projects are hosted on a single Trac instance, the current
behavior will retrieve changesets from all tracked projects.
This patch teaches Trac.js to get project-specific changesets from Trac.
We do this by replacing the parameter `changeset=on` to `repo-projectname=on`
when querying the Trac timeline.

To tell Trac to be aware of multi-project instances we leverage the
`options` parameter when creating a new instance:

new Trac("https://mytrac.com/", { projectIdentifier: "tracProjectName" });

If this option is not provided, the original behaviour will prevail.
Additionally, add corresponding tests.

* BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js:
(Trac): Reason about new optional parameter 'projectIdentifier'.
(Trac.prototype.revisionURL): Given a projectIdentifier, append it to the end of the URL.
(Trac.prototype._xmlTimelineURL): Given a projectIdentifier,
replace default parameter `changeset=on` with `repo-projectname=on`.
(Trac.prototype._convertCommitInfoElementToObject): Fix missing ';'.
* BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/resources/MockTrac.js:
(MockTrac): Add support for instantiating Trac with a projectIdentifier.
* BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/resources/tests.js:
(setup): Provide a multiple-project MockTrac instance to all test cases for testing.
Add the following tests:
test("revisionURL")
test("revisionURL with Trac Identifier")
test("_xmlTimelineURL")
test("_xmlTimelineURL with Trac Identifier")
(this.view._latestProductiveIteration): Fix missing ';'.

2017-01-30 Myles C. Maxfield <mmaxfield@apple.com>

Correct spacing regression on inter-element complex path shaping on some fonts

0 comments on commit 60143df

Please sign in to comment.