<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[211388] trunk/Tools</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/211388">211388</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2017-01-30 15:03:27 -0800 (Mon, 30 Jan 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add support for Trac instances that host multiple projects.
https://bugs.webkit.org/show_bug.cgi?id=167524

Patch by Kocsen Chung &lt;kocsen_chung@apple.com&gt; 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(&quot;https://mytrac.com/&quot;, { projectIdentifier: &quot;tracProjectName&quot; });

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(&quot;revisionURL&quot;)
    test(&quot;revisionURL with Trac Identifier&quot;)
    test(&quot;_xmlTimelineURL&quot;)
    test(&quot;_xmlTimelineURL with Trac Identifier&quot;)
(this.view._latestProductiveIteration): Fix missing ';'.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkToolsBuildSlaveSupportbuildwebkitorgconfigpublic_htmldashboardScriptsTracjs">trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js</a></li>
<li><a href="#trunkToolsBuildSlaveSupportbuildwebkitorgconfigpublic_htmldashboardScriptstestsresourcesMockTracjs">trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/resources/MockTrac.js</a></li>
<li><a href="#trunkToolsBuildSlaveSupportbuildwebkitorgconfigpublic_htmldashboardScriptstestsresourcestestsjs">trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/resources/tests.js</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkToolsBuildSlaveSupportbuildwebkitorgconfigpublic_htmldashboardScriptsTracjs"></a>
<div class="modfile"><h4>Modified: trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js (211387 => 211388)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js        2017-01-30 22:51:52 UTC (rev 211387)
+++ trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js        2017-01-30 23:03:27 UTC (rev 211388)
</span><span class="lines">@@ -30,7 +30,11 @@
</span><span class="cx">     console.assert(baseURL);
</span><span class="cx"> 
</span><span class="cx">     this.baseURL = baseURL;
</span><del>-    this._needsAuthentication = (typeof options === &quot;object&quot;) &amp;&amp; options[Trac.NeedsAuthentication] === true;
</del><ins>+    if (typeof options === &quot;object&quot;) {
+        this._needsAuthentication = options[Trac.NeedsAuthentication] === true;
+        // We expect the projectIdentifier option iff the target Trac instance is hosting multiple repositories &amp;&amp; Trac version &gt; 1.0
+        this._projectName = options[Trac.ProjectIdentifier];
+    }
</ins><span class="cx"> 
</span><span class="cx">     this.recordedCommits = []; // Will be sorted in ascending order.
</span><span class="cx"> };
</span><span class="lines">@@ -40,6 +44,7 @@
</span><span class="cx"> Trac.NO_MORE_REVISIONS = null;
</span><span class="cx"> 
</span><span class="cx"> Trac.NeedsAuthentication = &quot;needsAuthentication&quot;;
</span><ins>+Trac.ProjectIdentifier = &quot;projectIdentifier&quot;;
</ins><span class="cx"> Trac.UpdateInterval = 45000; // 45 seconds
</span><span class="cx"> 
</span><span class="cx"> Trac.Event = {
</span><span class="lines">@@ -103,7 +108,10 @@
</span><span class="cx"> 
</span><span class="cx">     revisionURL: function(revision)
</span><span class="cx">     {
</span><del>-        return this.baseURL + &quot;changeset/&quot; + encodeURIComponent(revision);
</del><ins>+        var url = this.baseURL + &quot;changeset/&quot; + encodeURIComponent(revision);
+        if (this._projectName)
+            url += '/' + encodeURIComponent(this._projectName);
+        return url;
</ins><span class="cx">     },
</span><span class="cx"> 
</span><span class="cx">     _xmlTimelineURL: function(fromDate, toDate)
</span><span class="lines">@@ -112,10 +120,14 @@
</span><span class="cx"> 
</span><span class="cx">         var fromDay = new Date(fromDate.getFullYear(), fromDate.getMonth(), fromDate.getDate());
</span><span class="cx">         var toDay = new Date(toDate.getFullYear(), toDate.getMonth(), toDate.getDate());
</span><ins>+        var changesetParameter = this._projectName ? &quot;repo-&quot; + this._projectName : &quot;changeset&quot;;
</ins><span class="cx"> 
</span><del>-        return this.baseURL + &quot;timeline?changeset=on&amp;format=rss&amp;max=0&quot; +
-            &quot;&amp;from=&quot; +  toDay.toISOString().slice(0, 10) +
-            &quot;&amp;daysback=&quot; + ((toDay - fromDay) / 1000 / 60 / 60 / 24);
</del><ins>+        return this.baseURL + &quot;timeline?&quot; +
+            changesetParameter + &quot;=on&quot; +
+            &quot;&amp;format=rss&quot; +
+            &quot;&amp;max=0&quot; +
+            &quot;&amp;from=&quot; + encodeURIComponent(toDay.toISOString().slice(0, 10)) +
+            &quot;&amp;daysback=&quot; + encodeURIComponent((toDay - fromDay) / 1000 / 60 / 60 / 24);
</ins><span class="cx">     },
</span><span class="cx"> 
</span><span class="cx">     _parseRevisionFromURL: function(url)
</span><span class="lines">@@ -150,7 +162,7 @@
</span><span class="cx">         var location = &quot;&quot;;
</span><span class="cx">         if (parsedDescription.firstChild &amp;&amp; parsedDescription.firstChild.className === &quot;changes&quot;) {
</span><span class="cx">             // We can extract branch information when trac.ini contains &quot;changeset_show_files=location&quot;.
</span><del>-            location = doc.evaluate(&quot;//strong&quot;, parsedDescription.firstChild, null, XPathResult.STRING_TYPE).stringValue
</del><ins>+            location = doc.evaluate(&quot;//strong&quot;, parsedDescription.firstChild, null, XPathResult.STRING_TYPE).stringValue;
</ins><span class="cx">             parsedDescription.removeChild(parsedDescription.firstChild);
</span><span class="cx">         }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsBuildSlaveSupportbuildwebkitorgconfigpublic_htmldashboardScriptstestsresourcesMockTracjs"></a>
<div class="modfile"><h4>Modified: trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/resources/MockTrac.js (211387 => 211388)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/resources/MockTrac.js        2017-01-30 22:51:52 UTC (rev 211387)
+++ trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/resources/MockTrac.js        2017-01-30 23:03:27 UTC (rev 211388)
</span><span class="lines">@@ -23,9 +23,15 @@
</span><span class="cx">  * THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx">  */
</span><span class="cx"> 
</span><del>-MockTrac = function()
</del><ins>+MockTrac = function(projectIdentifier)
</ins><span class="cx"> {
</span><del>-    Trac.call(this, &quot;https://trac.webkit.org/&quot;);
</del><ins>+    if (projectIdentifier) {
+        var options = { };
+        options[Trac.ProjectIdentifier] = projectIdentifier;
+        Trac.call(this, &quot;https://trac.webkit.org/&quot;, options);
+    } else {
+        Trac.call(this, &quot;https://trac.webkit.org/&quot;);
+    }
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> BaseObject.addConstructorFunctions(MockTrac);
</span></span></pre></div>
<a id="trunkToolsBuildSlaveSupportbuildwebkitorgconfigpublic_htmldashboardScriptstestsresourcestestsjs"></a>
<div class="modfile"><h4>Modified: trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/resources/tests.js (211387 => 211388)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/resources/tests.js        2017-01-30 22:51:52 UTC (rev 211387)
+++ trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/resources/tests.js        2017-01-30 23:03:27 UTC (rev 211388)
</span><span class="lines">@@ -41,6 +41,7 @@
</span><span class="cx"> module(&quot;Trac&quot;, {
</span><span class="cx">     setup: function() {
</span><span class="cx">         this.trac = new MockTrac();
</span><ins>+        this.tracWithIdentifier = new MockTrac(&quot;webkit&quot;);
</ins><span class="cx">     }
</span><span class="cx"> });
</span><span class="cx"> 
</span><span class="lines">@@ -121,6 +122,36 @@
</span><span class="cx">     equal(commits.length, 2, &quot;in range 33020, 33022&quot;);
</span><span class="cx"> });
</span><span class="cx"> 
</span><ins>+test(&quot;revisionURL&quot;, function()
+{
+    strictEqual(this.trac.revisionURL(&quot;33020&quot;), &quot;https://trac.webkit.org/changeset/33020&quot;, &quot;changeset URL matches for 33020&quot;);
+    strictEqual(this.trac.revisionURL(&quot;0e498db5d8e5b5a342631&quot;), &quot;https://trac.webkit.org/changeset/0e498db5d8e5b5a342631&quot;, &quot;changeset URL matches for 0e498db5d8e5b5a342631&quot;);
+});
+
+test(&quot;revisionURL with Trac Identifier&quot;, function()
+{
+    strictEqual(this.tracWithIdentifier.revisionURL(&quot;33020&quot;), &quot;https://trac.webkit.org/changeset/33020/webkit&quot;, &quot;changeset URL matches for 33020&quot;);
+    strictEqual(this.tracWithIdentifier.revisionURL(&quot;0e498db5d8e5b5a342631&quot;), &quot;https://trac.webkit.org/changeset/0e498db5d8e5b5a342631/webkit&quot;, &quot;changeset URL matches for 0e498db5d8e5b5a342631&quot;);
+});
+
+test(&quot;_xmlTimelineURL&quot;, function()
+{
+    var before = new Date(&quot;1/1/2017&quot;);
+    var after = new Date(&quot;1/2/2017&quot;);
+
+    strictEqual(this.trac._xmlTimelineURL(before, before), &quot;https://trac.webkit.org/timeline?changeset=on&amp;format=rss&amp;max=0&amp;from=2017-01-01&amp;daysback=0&quot;);
+    strictEqual(this.trac._xmlTimelineURL(before, after), &quot;https://trac.webkit.org/timeline?changeset=on&amp;format=rss&amp;max=0&amp;from=2017-01-02&amp;daysback=1&quot;);
+});
+
+test(&quot;_xmlTimelineURL with Trac Identifier&quot;, function()
+{
+    var before = new Date(&quot;1/1/2017&quot;);
+    var after = new Date(&quot;1/2/2017&quot;);
+
+    strictEqual(this.tracWithIdentifier._xmlTimelineURL(before, before), &quot;https://trac.webkit.org/timeline?repo-webkit=on&amp;format=rss&amp;max=0&amp;from=2017-01-01&amp;daysback=0&quot;);
+    strictEqual(this.tracWithIdentifier._xmlTimelineURL(before, after), &quot;https://trac.webkit.org/timeline?repo-webkit=on&amp;format=rss&amp;max=0&amp;from=2017-01-02&amp;daysback=1&quot;);
+});
+
</ins><span class="cx"> module(&quot;BuildBotQueueView&quot;, {
</span><span class="cx">     setup: function() {
</span><span class="cx">         this.trac = new MockTrac();
</span><span class="lines">@@ -179,7 +210,7 @@
</span><span class="cx">             revision: { &quot;openSource&quot;: &quot;33021&quot; },
</span><span class="cx">         };
</span><span class="cx">         return iteration;
</span><del>-    }
</del><ins>+    };
</ins><span class="cx">     var element = document.createElement(&quot;div&quot;);
</span><span class="cx">     var popover = new Dashboard.Popover();
</span><span class="cx">     this.view._presentPopoverForPendingCommits(element, popover, this.queue);
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (211387 => 211388)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2017-01-30 22:51:52 UTC (rev 211387)
+++ trunk/Tools/ChangeLog        2017-01-30 23:03:27 UTC (rev 211388)
</span><span class="lines">@@ -1,3 +1,41 @@
</span><ins>+2017-01-30  Kocsen Chung  &lt;kocsen_chung@apple.com&gt;
+
+        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(&quot;https://mytrac.com/&quot;, { projectIdentifier: &quot;tracProjectName&quot; });
+
+        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(&quot;revisionURL&quot;)
+            test(&quot;revisionURL with Trac Identifier&quot;)
+            test(&quot;_xmlTimelineURL&quot;)
+            test(&quot;_xmlTimelineURL with Trac Identifier&quot;)
+        (this.view._latestProductiveIteration): Fix missing ';'.
+
</ins><span class="cx"> 2017-01-30  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Correct spacing regression on inter-element complex path shaping on some fonts
</span></span></pre>
</div>
</div>

</body>
</html>