this.page = page;
this.lineNumberToReveal = lineNumberToReveal;
}
public void execute(IProgressMonitor monitor) throws CoreException {
final RevisionInformation info = new RevisionInformation();
final BlameCommand command = new BlameCommand(repository)
.setFollowFileRenames(true).setFilePath(path);
if (startCommit != null)
command.setStartCommit(startCommit);
else {
try {
command.setStartCommit(repository.resolve(Constants.HEAD));
} catch (IOException e) {
Activator
.error("Error resolving HEAD for showing annotations in repository: " + repository, e); //$NON-NLS-1$
return;
}
}
if (Activator.getDefault().getPreferenceStore()
.getBoolean(UIPreferences.BLAME_IGNORE_WHITESPACE))
command.setTextComparator(RawTextComparator.WS_IGNORE_ALL);
BlameResult result;
try {
result = command.call();
} catch (Exception e1) {
Activator.error(e1.getMessage(), e1);
return;
}
if (result == null)
return;
Map<RevCommit, BlameRevision> revisions = new HashMap<RevCommit, BlameRevision>();
int lineCount = result.getResultContents().size();
BlameRevision previous = null;
for (int i = 0; i < lineCount; i++) {
RevCommit commit = result.getSourceCommit(i);
String sourcePath = result.getSourcePath(i);
if (commit == null) {
// Unregister the current revision
if (previous != null) {
previous.register();
previous = null;
}
continue;
}
BlameRevision revision = revisions.get(commit);
if (revision == null) {
revision = new BlameRevision();
revision.setRepository(repository);
revision.setCommit(commit);
revision.setSourcePath(sourcePath);
revisions.put(commit, revision);
info.addRevision(revision);
}
revision.addSourceLine(i, result.getSourceLine(i));
if (previous != null)
if (previous == revision)
previous.addLine();