private static void rollbackUnderProgressIfNeeded(@NotNull final Project project, @NotNull final Label labelToRevert) {
    Runnable rollback = () -> {
      try {
        labelToRevert.revert(project, project.getBaseDir());
        VcsNotifier.getInstance(project)
          .notifyImportantWarning(PATCH_APPLY_ABORTED,
                                  VcsBundle.message("patch.apply.aborted.title"),
                                  VcsBundle.message("patch.apply.aborted.message"));
      }
      catch (LocalHistoryException e) {
        VcsNotifier.getInstance(project)
          .notifyImportantWarning(PATCH_APPLY_ROLLBACK_FAILED,
                                  VcsBundle.message("patch.apply.rollback.failed.title"),
                                  VcsBundle.message("patch.apply.rollback.failed.message"));
      }
    };
    if (ApplicationManager.getApplication().isDispatchThread()) {
      ProgressManager.getInstance()
        .runProcessWithProgressSynchronously(rollback, VcsBundle.message("patch.apply.rollback.progress.title"), true, project);
    }
    else {
      progress(VcsBundle.message("patch.apply.rollback.progress"));
      rollback.run();
    }
  }
private static void rollbackUnderProgressIfNeeded(@NotNull final Project project, @NotNull final Label labelToRevert)