OLD | NEW |
1 <!-- | 1 <!-- |
2 Copyright 2014 The Chromium Authors. All rights reserved. | 2 Copyright 2014 The Chromium Authors. All rights reserved. |
3 Use of this source code is governed by a BSD-style license that can be | 3 Use of this source code is governed by a BSD-style license that can be |
4 found in the LICENSE file. | 4 found in the LICENSE file. |
5 --> | 5 --> |
6 | 6 |
7 <link rel="import" href="../lib/net.html"> | 7 <link rel="import" href="../lib/net.html"> |
8 <link rel='import' href='ct-commit.html'> | 8 <link rel='import' href='ct-commit.html'> |
9 <link rel='import' href='ct-repositories.html'> | 9 <link rel='import' href='ct-repositories.html'> |
10 | 10 |
11 <script> | 11 <script> |
12 function CTCommitLog() { | 12 function CTCommitLog() { |
13 this.commits = {}; | 13 this.commits = {}; |
14 this.firstRevision = {}; | |
15 this.lastRevision = {}; | 14 this.lastRevision = {}; |
16 this._repositories = new CTRepositories(); | 15 this._repositories = new CTRepositories(); |
17 | 16 |
18 this._repositories.names.forEach(function(name) { | 17 this._repositories.names.forEach(function(name) { |
19 this.commits[name] = {}; | 18 this.commits[name] = {}; |
20 }.bind(this)); | 19 }.bind(this)); |
21 } | 20 } |
22 | 21 |
23 CTCommitLog.prototype.update = function() { | 22 CTCommitLog.prototype.update = function() { |
24 var requests = []; | 23 var requests = []; |
(...skipping 18 matching lines...) Expand all Loading... |
43 // data-binding properly updates all the <ct-commit>'s. | 42 // data-binding properly updates all the <ct-commit>'s. |
44 var existingCommit = this.commits[repository][revision]; | 43 var existingCommit = this.commits[repository][revision]; |
45 if (existingCommit && !existingCommit.isComplete) { | 44 if (existingCommit && !existingCommit.isComplete) { |
46 existingCommit.complete(author, message, revision); | 45 existingCommit.complete(author, message, revision); |
47 } else { | 46 } else { |
48 var commit = CTCommit.create(author, message, repositoryUrl, repository); | 47 var commit = CTCommit.create(author, message, repositoryUrl, repository); |
49 this.commits[repository][commit.revision] = commit; | 48 this.commits[repository][commit.revision] = commit; |
50 } | 49 } |
51 }.bind(this)); | 50 }.bind(this)); |
52 | 51 |
53 this._findFirstAndLastRevisions(repository); | 52 this._updateLastRevision(repository); |
54 } | 53 } |
55 | 54 |
56 CTCommitLog.prototype._findFirstAndLastRevisions = function(repository) { | 55 CTCommitLog.prototype._updateLastRevision = function(repository) { |
57 var sortedCommits = Object.keys(this.commits[repository]).sort(); | 56 var sortedCommits = Object.keys(this.commits[repository]).sort(); |
58 this.firstRevision[repository] = parseInt(sortedCommits.first()); | 57 this.lastRevision[repository] = sortedCommits.last(); |
59 this.lastRevision[repository] = parseInt(sortedCommits.last()); | |
60 } | 58 } |
61 | 59 |
62 CTCommitLog.prototype.range = function(repository, first, last) { | 60 CTCommitLog.prototype.range = function(repository, revisions) { |
63 var commits = []; | 61 var commits = []; |
64 for (var revision = first; revision <= last; revision++) { | 62 revisions.forEach(function(revision) { |
65 var commit = this.commits[repository][revision]; | 63 var commit = this.commits[repository][revision]; |
66 if (!commit) { | 64 if (!commit) { |
67 // FIXME: This is wrong. If we iterate through revisions and then later | 65 var url = this._repositories.repositories[repository].repositoryUrl; |
68 // in handleReponse we realize that this revision doesn't actually exist | 66 var commit = CTCommit.createIncomplete(url, revision, repository); |
69 // in the repo (e.g. because it corresponds to a branch commit), then we | 67 this.commits[repository][revision] = commit; |
70 // don't remove the incomplete commit. | 68 } |
71 var url = this._repositories.repositories[repository].repositoryUrl; | |
72 commit = CTCommit.createIncomplete(url, revision, repository); | |
73 this.commits[repository][revision] = commit; | |
74 } | |
75 | 69 |
76 if (commit) | 70 if (commit) |
77 commits.push(commit); | 71 commits.push(commit); |
78 } | 72 }.bind(this)); |
79 return commits; | 73 return commits; |
80 } | 74 } |
81 </script> | 75 </script> |
OLD | NEW |