Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: appengine/chromium_rietveld/new_static/model/patch_set.js

Issue 1155513002: [Rietveld] Add support for patchset dependencies (Closed) Base URL: https://chromium.googlesource.com/infra/infra@master
Patch Set: Fix lint issues in test Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 "use strict"; 5 "use strict";
6 6
7 // https://codereview.chromium.org/api/148223004/70001/?comments=true 7 // https://codereview.chromium.org/api/148223004/70001/?comments=true
8 function PatchSet(issue, id, sequence) 8 function PatchSet(issue, id, sequence)
9 { 9 {
10 this.files = []; // Array<PatchFile> 10 this.files = []; // Array<PatchFile>
11 this.sourceFiles = []; // Array<PatchFile> 11 this.sourceFiles = []; // Array<PatchFile>
12 this.testFiles = []; // Array<PatchFile> 12 this.testFiles = []; // Array<PatchFile>
13 this.created = ""; // Date 13 this.created = ""; // Date
14 this.messageCount = 0; 14 this.messageCount = 0;
15 this.draftCount = 0; 15 this.draftCount = 0;
16 this.lastModified = ""; // Date 16 this.lastModified = ""; // Date
17 this.issue = issue || null; 17 this.issue = issue || null;
18 this.owner = null // User 18 this.owner = null // User
19 this.title = ""; 19 this.title = "";
20 this.id = id || 0; 20 this.id = id || 0;
21 this.sequence = sequence || 0; 21 this.sequence = sequence || 0;
22 this.commit = false; 22 this.commit = false;
23 this.cqDryRun = false; 23 this.cqDryRun = false;
24 this.mostRecent = false; 24 this.mostRecent = false;
25 this.active = false; 25 this.active = false;
26 this.dependsOnPatchset = null;
27 this.dependentPatchsets = null; // Array<PatchSet>
26 Object.preventExtensions(this); 28 Object.preventExtensions(this);
27 } 29 }
28 30
29 PatchSet.DETAIL_URL = "/api/{1}/{2}/?comments=true&try_jobs=false"; 31 PatchSet.DETAIL_URL = "/api/{1}/{2}/?comments=true&try_jobs=false";
30 PatchSet.REVERT_URL = "/api/{1}/{2}/revert"; 32 PatchSet.REVERT_URL = "/api/{1}/{2}/revert";
31 PatchSet.DELETE_URL = "/{1}/patchset/{2}/delete"; 33 PatchSet.DELETE_URL = "/{1}/patchset/{2}/delete";
32 PatchSet.TITLE_URL = "/{1}/patchset/{2}/edit_patchset_title"; 34 PatchSet.TITLE_URL = "/{1}/patchset/{2}/edit_patchset_title";
35 PatchSet.PATCHSET_URL = "/{1}/#ps{2}";
36
37 PatchSet.prototype.getPatchsetUrl = function()
38 {
39 return PatchSet.PATCHSET_URL.assign(
40 encodeURIComponent(this.issue.id),
41 encodeURIComponent(this.id));
42 };
33 43
34 PatchSet.prototype.getDetailUrl = function() 44 PatchSet.prototype.getDetailUrl = function()
35 { 45 {
36 return PatchSet.DETAIL_URL.assign( 46 return PatchSet.DETAIL_URL.assign(
37 encodeURIComponent(this.issue.id), 47 encodeURIComponent(this.issue.id),
38 encodeURIComponent(this.id)); 48 encodeURIComponent(this.id));
39 }; 49 };
40 50
41 PatchSet.prototype.getRevertUrl = function() 51 PatchSet.prototype.getRevertUrl = function()
42 { 52 {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 throw new Error("Invalid patchset loaded " + data.issue + " != " + this. issue.id 126 throw new Error("Invalid patchset loaded " + data.issue + " != " + this. issue.id
117 + " or " + data.patchset + " != " + this.id); 127 + " or " + data.patchset + " != " + this.id);
118 } 128 }
119 129
120 this.owner = new User(data.owner); 130 this.owner = new User(data.owner);
121 // TODO(esprehn): The server calls it a message sometimes and a title others , 131 // TODO(esprehn): The server calls it a message sometimes and a title others ,
122 // lets always call it a title. 132 // lets always call it a title.
123 this.title = data.message || ""; 133 this.title = data.message || "";
124 this.lastModified = Date.utc.create(data.modified); 134 this.lastModified = Date.utc.create(data.modified);
125 this.created = Date.utc.create(data.created); 135 this.created = Date.utc.create(data.created);
136 if (data.depends_on_patchset) {
137 var tokens = data.depends_on_patchset.split(":");
138 var dependsOnIssue = new Issue(parseInt(tokens[0]));
139 dependsOnIssue.loadDetails();
140 this.dependsOnPatchset = new PatchSet(dependsOnIssue, parseInt(tokens[1]), 0);
141 }
142 if (data.dependent_patchsets && data.dependent_patchsets.length != 0) {
143 this.dependentPatchsets = [];
144 data.dependent_patchsets.forEach(function(dependent_patchset, i) {
145 var tokens = dependent_patchset.split(":");
146 var dependentIssue = new Issue(parseInt(tokens[0]));
147 dependentIssue.loadDetails();
148 var dependentPatchset = new PatchSet(dependentIssue, parseInt(tokens[1 ]), i + 1);
149 this.dependentPatchsets.push(dependentPatchset);
150 }, this);
151 }
126 152
127 Object.keys(data.files || {}, function(name, value) { 153 Object.keys(data.files || {}, function(name, value) {
128 var file = new PatchFile(patchset, name); 154 var file = new PatchFile(patchset, name);
129 file.parseData(value); 155 file.parseData(value);
130 patchset.files.push(file); 156 patchset.files.push(file);
131 }); 157 });
132 158
133 this.files.sort(PatchFile.compare); 159 this.files.sort(PatchFile.compare);
134 // Make a doubly linked list of files 160 // Make a doubly linked list of files
135 if (this.files.length > 1) { 161 if (this.files.length > 1) {
136 for (var i = 0; i < this.files.length; ++i) { 162 for (var i = 0; i < this.files.length; ++i) {
137 this.files[i].nextFile = this.files[i + 1]; 163 this.files[i].nextFile = this.files[i + 1];
138 this.files[i].previousFile = this.files[i - 1]; 164 this.files[i].previousFile = this.files[i - 1];
139 } 165 }
140 } 166 }
141 167
142 this.files.forEach(function(file) { 168 this.files.forEach(function(file) {
143 if (file.isLayoutTest) 169 if (file.isLayoutTest)
144 this.testFiles.push(file); 170 this.testFiles.push(file);
145 else 171 else
146 this.sourceFiles.push(file); 172 this.sourceFiles.push(file);
147 }, this); 173 }, this);
148 }; 174 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698