141
140
final VcsFileRevision revision,
142
141
final List<VcsFileRevision> revisions,
143
142
final VirtualFile file) throws VcsException {
145
GitSimpleHandler h = new GitSimpleHandler(myProject, GitUtil.getGitRoot(myProject, repositoryFilePath), GitHandler.ANNOTATE);
147
h.setStdoutSuppressed(true);
148
h.setCharset(file.getCharset());
149
h.addParameters("-p", "-l", "-t", "-M");
150
if (revision == null) {
151
h.addParameters("HEAD");
154
h.addParameters(revision.getRevisionNumber().asString());
157
h.addRelativePaths(repositoryFilePath);
158
String output = h.run();
160
143
Bzr bzr = Bzr.forBzrRoot( GitUtil.getGitRoot(myProject, repositoryFilePath) );
161
IBazaarAnnotation output = bzr.annotate( repositoryFilePath, revision != null ? ((BzrRevisionNumber)revision.getRevisionNumber()).getBzrRevision() : null );
162
GitFileAnnotation annotation = new GitFileAnnotation(myProject, file, revision == null);
167
BzrRevisionNumber revision;
169
HashMap<String, CommitInfo> commits = new HashMap<String, CommitInfo>();
170
for (StringScanner s = new StringScanner(output); s.hasMoreData();) {
172
String commitHash = s.spaceToken();
173
if (commitHash.equals(BzrRevisionNumber.NOT_COMMITED_HASH)) {
176
s.spaceToken(); // skip revision line number
177
int lineNum = Integer.parseInt(s.spaceToken());
179
// parse commit information
180
CommitInfo commit = commits.get(commitHash);
181
if (commit != null) {
182
while (s.hasMoreData() && !s.startsWith('\t')) {
187
commit = new CommitInfo();
188
while (s.hasMoreData() && !s.startsWith('\t')) {
189
String key = s.spaceToken();
190
String value = s.line();
191
if (commitHash != null && AUTHOR_KEY.equals(key)) {
192
commit.author = value;
194
if (commitHash != null && COMMITTER_TIME_KEY.equals(key)) {
195
commit.date = GitUtil.parseTimestamp(value);
196
commit.revision = new BzrRevisionNumber(commitHash, commit.date);
199
commits.put(commitHash, commit);
202
if (!s.hasMoreData()) {
203
// if the file is empty, the next line will not start with tab and it will be
208
String line = s.line(true);
209
annotation.appendLineInfo(commit.date, commit.revision, commit.author, line, lineNum);
212
for ( int linenum = 0; linenum < output.getNumberOfLines(); linenum++ ) {
213
Date annoDate = output.getDate( linenum );
214
annotation.appendLineInfo(
216
BzrRevisionNumber.createRevision( output.getRevision( linenum ), annoDate ),
217
output.getAuthor( linenum ),
218
output.getline( linenum ), linenum + 1 );
219
// @TODO: set progress?
144
// IBazaarAnnotation output = bzr.annotate( repositoryFilePath, revision != null ? ((BzrRevisionNumber)revision.getRevisionNumber()).getBzrRevision() : null );
145
GitFileAnnotation annotation = new GitFileAnnotation(myProject, file, revision == null, revision.getRevisionNumber());
146
// for ( int linenum = 0; linenum < output.getNumberOfLines(); linenum++ ) {
147
// Date annoDate = output.getDate( linenum );
148
// annotation.appendLineInfo(
150
// BzrRevisionNumber.createRevision( output.getRevision( linenum ), annoDate ),
151
// output.getAuthor( linenum ),
152
// output.getline( linenum ), linenum + 1 );
153
// @TODO: set progress?
221
155
annotation.addLogEntries(revisions);
222
156
return annotation;