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

Unified Diff: Tools/GardeningServer/model/ct-commit-log.html

Issue 485253004: [Sheriff-o-matic] Remove race condition on the commit list. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: names Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: Tools/GardeningServer/model/ct-commit-log.html
diff --git a/Tools/GardeningServer/model/ct-commit-log.html b/Tools/GardeningServer/model/ct-commit-log.html
index fa39b8252dafbeaa323e00853a540c4740f28e09..6bfa08dbe321a2003d56cc7d1720bb71a228eaba 100644
--- a/Tools/GardeningServer/model/ct-commit-log.html
+++ b/Tools/GardeningServer/model/ct-commit-log.html
@@ -14,6 +14,10 @@ function CTCommitLog() {
this.firstRevision = {};
this.lastRevision = {};
this._repositories = new CTRepositories();
+
+ this._repositories.names.forEach(function(name) {
+ this.commits[name] = {};
+ }.bind(this));
}
CTCommitLog.prototype.update = function() {
@@ -27,14 +31,23 @@ CTCommitLog.prototype.update = function() {
}
CTCommitLog.prototype._handleResponse = function(repositoryUrl, repository, json) {
- if (!this.commits[repository])
- this.commits[repository] = {};
-
// FIXME: Fix googlesource to not do this outdated JSON XSS mitigation.
json = json.substring(')]}\n'.length);
JSON.parse(json).log.forEach(function(entry) {
- var commit = CTCommit.create(entry.author.name, entry.message, repositoryUrl, repository);
- this.commits[repository][commit.revision] = commit;
+ var author = entry.author.name;
+ var message = entry.message;
+ var revision = CTCommit.findRevision(message);
+
+ // Check for existing commit for that revision, and possibly complete it.
+ // We update the existing commit instead of creating a new one so that the
+ // data-binding properly updates all the <ct-commit>'s.
+ var existingCommit = this.commits[repository][revision];
+ if (existingCommit && !existingCommit.isComplete) {
+ existingCommit.complete(author, message, revision);
+ } else {
+ var commit = CTCommit.create(author, message, repositoryUrl, repository);
+ this.commits[repository][commit.revision] = commit;
+ }
}.bind(this));
this._findFirstAndLastRevisions(repository);
@@ -49,17 +62,19 @@ CTCommitLog.prototype._findFirstAndLastRevisions = function(repository) {
CTCommitLog.prototype.range = function(repository, first, last) {
var commits = [];
for (var revision = first; revision <= last; revision++) {
- // Until we've seen a commit we have data for, fill in dummy data
- // so that we show something. Assume that we have the correct data
- // for all the commits after the first one we have data for.
- if (revision >= this.firstRevision[repository]) {
- var commit = this.commits[repository][revision];
- if (commit)
- commits.push(commit);
- } else {
- var url = this._repositories.repositories[repository].repositoryUrl;
- commits.push(CTCommit.createIncomplete(url, revision, repository));
- }
+ var commit = this.commits[repository][revision];
+ if (!commit) {
+ // FIXME: This is wrong. If we iterate through revisions and then later
+ // in handleReponse we realize that this revision doesn't actually exist
+ // in the repo (e.g. because it corresponds to a branch commit), then we
+ // don't remove the incomplete commit.
+ var url = this._repositories.repositories[repository].repositoryUrl;
+ commit = CTCommit.createIncomplete(url, revision, repository);
+ this.commits[repository][revision] = commit;
+ }
+
+ if (commit)
+ commits.push(commit);
}
return commits;
}
« no previous file with comments | « Tools/GardeningServer/model/ct-commit-list-mock.html ('k') | Tools/GardeningServer/model/ct-commit-log-mock.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698