public static void showError(final Project project, final String message, final boolean error) {
   final Application application = ApplicationManager.getApplication();
   if (application.isUnitTestMode()) {
     return;
   }
   final String title = VcsBundle.message("patch.apply.dialog.title");
   final Runnable messageShower =
       new Runnable() {
         @Override
         public void run() {
           if (error) {
             Messages.showErrorDialog(project, message, title);
           } else {
             Messages.showInfoMessage(project, message, title);
           }
         }
       };
   WaitForProgressToShow.runOrInvokeLaterAboveProgress(
       new Runnable() {
         @Override
         public void run() {
           messageShower.run();
         }
       },
       null,
       project);
 }
    private void doRefresh(final Project project, final List<Change> changesToRefresh) {
      final String actionName = VcsBundle.message("changes.action.rollback.text");
      final LocalHistoryAction action = LocalHistory.getInstance().startAction(actionName);

      final Runnable forAwtThread =
          new Runnable() {
            public void run() {
              action.finish();
              LocalHistory.getInstance()
                  .putSystemLabel(
                      myProject,
                      (myLocalHistoryActionName == null) ? actionName : myLocalHistoryActionName,
                      -1);
              final VcsDirtyScopeManager manager =
                  PeriodicalTasksCloser.getInstance()
                      .safeGetComponent(project, VcsDirtyScopeManager.class);
              for (Change change : changesToRefresh) {
                final ContentRevision beforeRevision = change.getBeforeRevision();
                final ContentRevision afterRevision = change.getAfterRevision();
                if ((!change.isIsReplaced())
                    && beforeRevision != null
                    && Comparing.equal(beforeRevision, afterRevision)) {
                  manager.fileDirty(beforeRevision.getFile());
                } else {
                  if (beforeRevision != null) {
                    final FilePath parent = beforeRevision.getFile().getParentPath();
                    if (parent != null) {
                      manager.dirDirtyRecursively(parent);
                    }
                  }
                  if (afterRevision != null) {
                    final FilePath parent = afterRevision.getFile().getParentPath();
                    if (parent != null) {
                      manager.dirDirtyRecursively(parent);
                    }
                  }
                }
              }

              myAfterRefresh.run();
            }
          };

      RefreshVFsSynchronously.updateChangesForRollback(changesToRefresh);

      WaitForProgressToShow.runOrInvokeLaterAboveProgress(forAwtThread, null, project);
    }
  /**
   * Invokes {@link com.intellij.openapi.diff.DiffManager#getDiffTool()} to show difference between
   * the given revisions of the given file.
   *
   * @param project project under vcs control.
   * @param filePath file which revisions are compared.
   * @param revision1 first revision - 'before', to the left.
   * @param revision2 second revision - 'after', to the right.
   * @throws com.intellij.openapi.vcs.VcsException
   * @throws java.io.IOException
   */
  public static void showDiff(
      @NotNull final Project project,
      @NotNull FilePath filePath,
      @NotNull VcsFileRevision revision1,
      @NotNull VcsFileRevision revision2,
      @NotNull String title1,
      @NotNull String title2)
      throws VcsException, IOException {
    final byte[] content1 = loadRevisionContent(revision1);
    final byte[] content2 = loadRevisionContent(revision2);

    final SimpleDiffRequest diffData = new SimpleDiffRequest(project, filePath.getPresentableUrl());
    diffData.addHint(DiffTool.HINT_SHOW_FRAME);
    final Document doc = filePath.getDocument();
    final Charset charset = filePath.getCharset();
    final FileType fileType = filePath.getFileType();
    diffData.setContentTitles(title1, title2);
    final Ref<VirtualFile> f1 = new Ref<VirtualFile>(null);
    final Ref<VirtualFile> f2 = new Ref<VirtualFile>(null);

    if (fileType.isBinary()) {
      final File file1 =
          FileUtil.createTempFile(revision1.getRevisionNumber().asString(), filePath.getName());
      final File file2 =
          FileUtil.createTempFile(revision2.getRevisionNumber().asString(), filePath.getName());
      try {
        final FileOutputStream fos1 = new FileOutputStream(file1);
        fos1.write(content1);
        final FileOutputStream fos2 = new FileOutputStream(file2);
        fos2.write(content2);
        fos1.close();
        fos2.close();
        f1.set(LocalFileSystem.getInstance().findFileByIoFile(file1));
        f2.set(LocalFileSystem.getInstance().findFileByIoFile(file2));
      } catch (Exception e) { //
      }
    }
    if (f1.isNull() || f2.isNull()) {
      diffData.setContents(
          createContent(project, content1, revision1, doc, charset, fileType, filePath.getPath()),
          createContent(project, content2, revision2, doc, charset, fileType, filePath.getPath()));
    } else {
      diffData.setContents(
          createFileContent(project, f1.get(), revision1),
          createFileContent(project, f2.get(), revision2));
    }
    WaitForProgressToShow.runOrInvokeLaterAboveProgress(
        new Runnable() {
          public void run() {
            DiffManager.getInstance().getDiffTool().show(diffData);
            if (!f1.isNull() || !f2.isNull()) {
              Disposer.register(
                  project,
                  new Disposable() {
                    @Override
                    public void dispose() {
                      ApplicationManager.getApplication()
                          .runWriteAction(
                              new Runnable() {
                                public void run() {
                                  try {
                                    if (!f1.isNull()) {
                                      f1.get().delete(this);
                                    }
                                    if (!f2.isNull()) {
                                      f2.get().delete(this);
                                    }
                                  } catch (IOException e) { //
                                  }
                                }
                              });
                    }
                  });
            }
          }
        },
        null,
        project);
  }