public void doRollback(
      final Collection<Change> changes,
      final boolean deleteLocallyAddedFiles,
      @Nullable final Runnable afterVcsRefreshInAwt,
      @Nullable final String localHistoryActionName) {
    final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
    final Runnable notifier = changeListManager.prepareForChangeDeletion(changes);
    final Runnable afterRefresh =
        new Runnable() {
          public void run() {
            changeListManager.invokeAfterUpdate(
                new Runnable() {
                  public void run() {
                    notifier.run();
                    if (afterVcsRefreshInAwt != null) {
                      afterVcsRefreshInAwt.run();
                    }
                  }
                },
                InvokeAfterUpdateMode.SILENT,
                "Refresh change lists after update",
                ModalityState.current());
          }
        };

    final Runnable rollbackAction =
        new MyRollbackRunnable(
            changes, deleteLocallyAddedFiles, afterRefresh, localHistoryActionName);

    if (ApplicationManager.getApplication().isDispatchThread()) {
      ProgressManager.getInstance()
          .run(
              new Task.Backgroundable(
                  myProject,
                  VcsBundle.message("changes.action.rollback.text"),
                  true,
                  new PerformInBackgroundOption() {
                    public boolean shouldStartInBackground() {
                      return VcsConfiguration.getInstance(myProject).PERFORM_ROLLBACK_IN_BACKGROUND;
                    }

                    public void processSentToBackground() {
                      VcsConfiguration.getInstance(myProject).PERFORM_ROLLBACK_IN_BACKGROUND = true;
                    }
                  }) {
                public void run(@NotNull ProgressIndicator indicator) {
                  rollbackAction.run();
                }
              });
    } else {
      rollbackAction.run();
    }
    ((ChangeListManagerImpl) changeListManager).showLocalChangesInvalidated();
  }