Bug 147961 - Refactor BuildbotQueueView._presentPopoverForPendingCommits to work more generically with repositories other than "openSource" and "internal".
Summary: Refactor BuildbotQueueView._presentPopoverForPendingCommits to work more gene...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-12 17:30 PDT by Jason Marcell
Modified: 2015-08-17 12:45 PDT (History)
6 users (show)

See Also:


Attachments
Patch (3.85 KB, patch)
2015-08-12 17:34 PDT, Jason Marcell
no flags Details | Formatted Diff | Diff
Patch (3.88 KB, patch)
2015-08-13 16:01 PDT, Jason Marcell
no flags Details | Formatted Diff | Diff
Patch (3.82 KB, patch)
2015-08-14 14:47 PDT, Jason Marcell
no flags Details | Formatted Diff | Diff
Patch (3.73 KB, patch)
2015-08-17 10:33 PDT, Jason Marcell
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jason Marcell 2015-08-12 17:30:56 PDT
Refactor BuildbotQueueView._presentPopoverForPendingCommits to work more generically with repositories other than "openSource" and "internal".
Comment 1 Jason Marcell 2015-08-12 17:34:26 PDT
Created attachment 258859 [details]
Patch
Comment 2 Daniel Bates 2015-08-13 14:24:19 PDT
Comment on attachment 258859 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=258859&action=review

> Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotQueueView.js:172
> +                if (shouldAddDivider)
> +                    this._addDividerToPopover(content);
>  
> -        if (linesForOpenSource.length && linesForInternal.length)
> -            this._addDividerToPopover(content);
> +                for (var i = 0; i != lines.length; ++i)
> +                    content.appendChild(lines[i]);
>  

This is not correct because we always add a divider regardless of whether there were popover lines.
Comment 3 Daniel Bates 2015-08-13 14:26:08 PDT
(In reply to comment #2)
> This is not correct because we always add a divider regardless of whether
> there were popover lines.

I meant to write:

This is not correct because we always add a divider regardless of whether there were popover lines when shouldAddDivider is true.
Comment 4 Jason Marcell 2015-08-13 14:36:58 PDT
I see. I think we want that to say:

if (lines.length)
    shouldAddDivider = true;

Right?
Comment 5 Jason Marcell 2015-08-13 16:01:46 PDT
Created attachment 258946 [details]
Patch
Comment 6 Jason Marcell 2015-08-13 16:02:35 PDT
Comment on attachment 258946 [details]
Patch

Now checking lines.length before adding the divider.
Comment 7 Daniel Bates 2015-08-14 14:15:30 PDT
Comment on attachment 258946 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=258946&action=review

> Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotQueueView.js:174
> +                if (lines.length)
> +                    shouldAddDivider = true;

This is not correct. Suppose there three repositories A, B, C and when processing these repositories (in this order) lines.length = 1, 0, 1, respectively. Then the output content will look like A_1, "divider", "divider", C_1.
Comment 8 Daniel Bates 2015-08-14 14:17:09 PDT
(In reply to comment #7)
> [...]
> Then the output content will look like A_1, "divider", "divider", C_1.

I should add that we want the output content to look like:

A_1, "divider", C_1
Comment 9 Jason Marcell 2015-08-14 14:47:43 PDT
Created attachment 259046 [details]
Patch
Comment 10 Jason Marcell 2015-08-14 14:49:14 PDT
I reset the shouldAddDivider variable after adding a divider.

I also moved the lines variable assignment closer to it's usage.
Comment 11 Daniel Bates 2015-08-14 18:03:36 PDT
Comment on attachment 259046 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=259046&action=review

> Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotQueueView.js:177
> +        var shouldAddDivider = false;
> +        var sortedRepositories = Dashboard.sortedRepositories;
> +        for (var i = 0; i < sortedRepositories.length; i++) {
> +            var repository = sortedRepositories[i];
> +            var trac = repository.trac;
> +            var repositoryName = repository.name;
> +            var latestProductiveRevisionNumber = latestProductiveIteration.revision[repositoryName];
> +            var lines = [];
> +            if (latestProductiveRevisionNumber && trac.latestRecordedRevisionNumber) {
> +                if (shouldAddDivider) {
> +                    this._addDividerToPopover(content);
> +                    shouldAddDivider = false;
> +                }
> +
> +                lines = this._popoverLinesForCommitRange(trac, queue.branch[repositoryName], latestProductiveRevisionNumber + 1, trac.latestRecordedRevisionNumber);
> +                for (var i = 0; i != lines.length; ++i)
> +                    content.appendChild(lines[i]);
> +
> +                if (lines.length)
> +                    shouldAddDivider = true;
> +            }
> +        }

This is not correct. Suppose there are three repositories A, B and when processing these repositories (in this order) lines.length = 1, 0, respectively. Then the output content will look like A_1, "divider". But it should be A_1.

Maybe something like this will work:

var shouldAddDivider = false;
var sortedRepositories = Dashboard.sortedRepositories;
for (var i = 0; i < sortedRepositories.length; ++i) {
    var repository = sortedRepositories[i];
    var trac = repository.trac;
    var repositoryName = repository.name;
    var latestProductiveRevisionNumber = latestProductiveIteration.revision[repositoryName];
    if (!latestProductiveRevisionNumber || !trac.latestRecordedRevisionNumber)
        continue;
    var lines = this._popoverLinesForCommitRange(trac, queue.branch[repositoryName], latestProductiveRevisionNumber + 1, trac.latestRecordedRevisionNumber);
    var length = lines.length;
    if (length && shouldAddDivider)
        this._addDividerToPopover(content);
    for (var i = 0; i < length; ++i)
        content.appendChild(lines[i]);
    shouldAddDivider = shouldAddDivider || length > 0;
}
Comment 12 Jason Marcell 2015-08-17 10:33:25 PDT
Created attachment 259161 [details]
Patch
Comment 13 Jason Marcell 2015-08-17 10:35:34 PDT
Comment on attachment 259161 [details]
Patch

Thanks, Dan. I looked over your suggested change over the weekend. It looks correct and also very concise.
Comment 14 WebKit Commit Bot 2015-08-17 12:45:18 PDT
Comment on attachment 259161 [details]
Patch

Clearing flags on attachment: 259161

Committed r188533: <http://trac.webkit.org/changeset/188533>
Comment 15 WebKit Commit Bot 2015-08-17 12:45:23 PDT
All reviewed patches have been landed.  Closing bug.