Package org.eclipse.egit.core.op

Examples of org.eclipse.egit.core.op.RevertCommitOperation


    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;
  }
View Full Code Here

TOP

Related Classes of org.eclipse.egit.core.op.RevertCommitOperation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.