@Override
  public void actionPerformed(@NotNull final AnActionEvent e) {
    Project project = e.getData(CommonDataKeys.PROJECT);
    if (project == null) return;
    VirtualFile baseDir = Objects.requireNonNull(project.getBaseDir());
    final Change[] changes = getChanges(e, false);
    if (changes == null || changes.length == 0) return;
    final List<Change> changesList = new ArrayList<>();
    Collections.addAll(changesList, changes);
    FileDocumentManager.getInstance().saveAllDocuments();

    final ChangeList[] changeLists = e.getData(VcsDataKeys.CHANGE_LISTS);

    String title = VcsBundle.message("changes.progress.title.choice.revert.apply.changes", myReverse ? 0 : 1);
    String errorPrefix = VcsBundle.message("changes.dialog.message.failed.to.revert.apply.changes", myReverse ? 0 : 1);

    LocalChangeList targetList;
    if (ChangeListManager.getInstance(project).areChangeListsEnabled()) {
      ChangeListChooser chooser = new ChangeListChooser(project, VcsBundle.message("revert.changes.changelist.chooser.title"));
      if (changeLists != null && changeLists.length > 0) {
        String defaultName = VcsBundle.message("changes.revert.apply.change.list.name", myReverse ? 0 : 1, changeLists[0].getName());
        chooser.setSuggestedName(defaultName);
      }
      if (!chooser.showAndGet()) return;

      targetList = chooser.getSelectedList();
    }
    else {
      targetList = null;
    }

    ProgressManager.getInstance().run(new Task.Backgroundable(project, title, true) {
      @Override
      public void run(@NotNull ProgressIndicator indicator) {
        try {
          List<Change> preprocessed = ChangesPreprocess.preprocessChangesRemoveDeletedForDuplicateMoved(changesList);
          List<FilePatch> patches = IdeaTextPatchBuilder.buildPatch(project, preprocessed, baseDir.toNioPath(), myReverse, false);
          String activityName = myReverse ? VcsBundle.message("activity.name.rollback") : VcsBundle.message("activity.name.apply.patch");
          ActivityId activityId = myReverse ? VcsActivity.Rollback : VcsActivity.ApplyPatch;
          new PatchApplier(project, baseDir, new ArrayList<>(patches), targetList, null, false, null, null,
                           activityName, activityId).execute();
        }
        catch (final VcsException ex) {
          WaitForProgressToShow.runOrInvokeLaterAboveProgress(() -> {
            Messages.showErrorDialog(project, errorPrefix + ex.getMessage(), title);
          }, null, project);
          indicator.cancel();
        }
      }
    });
  }
@Override
  public void actionPerformed(@NotNull final AnActionEvent e)