void (@NotNull final AnActionEvent e) { final Project project = e.getRequiredData(CommonDataKeys.PROJECT); final VirtualFile baseDir = project.getBaseDir(); assert baseDir != null; 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); new PatchApplier(project, baseDir, new ArrayList<>(patches), targetList, null).execute(); } catch (final VcsException ex) { WaitForProgressToShow.runOrInvokeLaterAboveProgress(() -> { Messages.showErrorDialog(project, errorPrefix + ex.getMessage(), title); }, null, project); indicator.cancel(); } } }); }