final Shell shell = getPart(event).getSite().getShell();
final List<RevCommit> commits = new ArrayList<RevCommit>();
for (RepositoryCommit repoCommit : repoCommits)
commits.add(repoCommit.getRevCommit());
final RevertCommitOperation op = new RevertCommitOperation(repo,
commits);
Job job = new WorkspaceJob(MessageFormat.format(
UIText.RevertHandler_JobName, Integer.valueOf(commits.size()))) {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) {
try {
op.execute(monitor);
RevCommit newHead = op.getNewHead();
List<Ref> revertedRefs = op.getRevertedRefs();
if (newHead != null && revertedRefs.isEmpty())
showRevertedDialog(shell);
if (newHead == null) {
RevCommit newestUnmergedCommit = null;
for (RevCommit commit : commits) {
if (!contains(revertedRefs, commit)) {
newestUnmergedCommit = commit;
break;
}
}
showFailureDialog(shell, newestUnmergedCommit,
op.getFailingResult());
}
} catch (CoreException e) {
Activator.handleError(UIText.RevertOperation_InternalError,
e, true);
}
return Status.OK_STATUS;
}
@Override
public boolean belongsTo(Object family) {
if (JobFamilies.REVERT_COMMIT.equals(family))
return true;
return super.belongsTo(family);
}
};
job.setUser(true);
job.setRule(op.getSchedulingRule());
job.schedule();
return null;
}