garden-o-matic should have a "rebaseline" button
[WebKit-https.git] / Tools / Scripts / webkitpy / tool / servers / data / gardeningserver / checkout.js
1 var checkout = checkout || {};
2
3 (function() {
4
5 var kWebKitTrunk = 'http://svn.webkit.org/repository/webkit/trunk/';
6
7 function subversionURLAtRevision(subversionURL, revision)
8 {
9     return subversionURL + '?r=' + revision;
10 }
11
12 checkout.subversionURLForTest = function(testName)
13 {
14     return kWebKitTrunk + 'LayoutTests/' + testName;
15 }
16
17 checkout.existsAtRevision = function (subversionURL, revision, callback)
18 {
19     $.ajax({
20         method: 'HEAD',
21         url: subversionURLAtRevision(subversionURL, revision), 
22         success: function() {
23             callback(true);
24         },
25         error: function() {
26             callback(false);
27         }
28     });
29 };
30
31 checkout.rebaseline = function(builderName, testName, failureTypeList, callback)
32 {
33     var extensionList = [];
34
35     $.each(failureTypeList, function(index, failureType) {
36         extensionList = extensionList.concat(results.failureTypeToExtensionList(failureType));
37     });
38
39     var requestsInFlight = extensionList.length;
40
41     if (!requestsInFlight)
42         callback();
43
44     $.each(extensionList, function(index, extension) {
45         $.post('/rebaseline?' + $.param({
46             'builder': builderName,
47             'test': testName,
48             // FIXME: Rename "suffix" query parameter to "extension".
49             'suffix': extension
50         }), function() {
51             --requestsInFlight;
52             if (!requestsInFlight)
53                 callback();
54         });
55     });
56 };
57
58 })();