void (@NotNull Collection<? extends Change> changes, boolean deleteLocallyAddedFiles, @Nullable Runnable afterVcsRefreshInAwt, @Nullable @Nls String localHistoryActionName, boolean honorExcludedFromCommit) { ProgressManager.getInstance().executeNonCancelableSection(() -> { ChangeListManagerImpl changeListManager = ChangeListManagerImpl.getInstanceImpl(myProject); Collection<LocalChangeList> affectedChangelists = changeListManager.getAffectedLists(changes); final LocalHistoryAction action = LocalHistory.getInstance().startAction(myOperationName); final Runnable afterRefresh = () -> { action.finish(); LocalHistory.getInstance().putSystemLabel(myProject, notNull(localHistoryActionName, myOperationName), -1); InvokeAfterUpdateMode updateMode = myInvokedFromModalContext ? InvokeAfterUpdateMode.SYNCHRONOUS_CANCELLABLE : InvokeAfterUpdateMode.SILENT; changeListManager.invokeAfterUpdate(() -> { for (LocalChangeList list : affectedChangelists) { changeListManager.scheduleAutomaticEmptyChangeListDeletion(list); } if (afterVcsRefreshInAwt != null) { afterVcsRefreshInAwt.run(); } }, updateMode, VcsBundle.message("changes.refresh.changelists.after.update"), ModalityState.current()); }; List<Change> otherChanges = revertPartialChanges(changes, honorExcludedFromCommit); if (otherChanges.isEmpty()) { WaitForProgressToShow.runOrInvokeLaterAboveProgress(afterRefresh, null, myProject); return; } final Runnable rollbackAction = new MyRollbackRunnable(otherChanges, deleteLocallyAddedFiles, afterRefresh); if (ApplicationManager.getApplication().isDispatchThread() && !myInvokedFromModalContext) { ProgressManager.getInstance().run(new Task.Backgroundable(myProject, myOperationName, false) { @Override public void run(@NotNull ProgressIndicator indicator) { rollbackAction.run(); } }); } else if (myInvokedFromModalContext) { ProgressManager.getInstance().run(new Task.Modal(myProject, myOperationName, false) { @Override public void run(@NotNull ProgressIndicator indicator) { rollbackAction.run(); } }); } else { rollbackAction.run(); } changeListManager.showLocalChangesInvalidated(); }); }