use of org.eclipse.jface.text.revisions.RevisionInformation in project egit by eclipse.
the class BlameOperation method execute.
@Override
public void execute(IProgressMonitor monitor) throws CoreException {
SubMonitor progress = SubMonitor.convert(monitor, 3);
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, // $NON-NLS-1$
e);
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;
}
progress.worked(1);
if (result == null)
return;
Map<RevCommit, BlameRevision> revisions = new HashMap<>();
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();
else {
previous.register();
previous = revision.reset(i);
}
else
previous = revision.reset(i);
}
if (previous != null)
previous.register();
progress.worked(1);
if (shell.isDisposed()) {
return;
}
if (fileRevision != null) {
storage = fileRevision.getStorage(progress.newChild(1));
} else {
progress.worked(1);
}
shell.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
openEditor(info);
}
});
}
Aggregations