Exemplo n.º 1
0
    private void doRun() {
      myIndicator = ProgressManager.getInstance().getProgressIndicator();

      final List<Change> changesToRefresh = new ArrayList<Change>();
      try {
        ChangesUtil.processChangesByVcs(
            myProject,
            myChanges,
            new ChangesUtil.PerVcsProcessor<Change>() {
              public void process(AbstractVcs vcs, List<Change> changes) {
                final RollbackEnvironment environment = vcs.getRollbackEnvironment();
                if (environment != null) {
                  changesToRefresh.addAll(changes);

                  if (myIndicator != null) {
                    myIndicator.setText(vcs.getDisplayName() + ": performing rollback...");
                    myIndicator.setIndeterminate(false);
                    myIndicator.checkCanceled();
                  }
                  environment.rollbackChanges(
                      changes,
                      myExceptions,
                      new RollbackProgressModifier(changes.size(), myIndicator));
                  if (myIndicator != null) {
                    myIndicator.setText2("");
                    myIndicator.checkCanceled();
                  }

                  if (myExceptions.isEmpty() && myDeleteLocallyAddedFiles) {
                    deleteAddedFilesLocally(changes);
                  }
                }
              }
            });
      } catch (ProcessCanceledException e) {
        // still do refresh
      }

      if (myIndicator != null) {
        myIndicator.startNonCancelableSection();
        myIndicator.setIndeterminate(true);
        myIndicator.setText2("");
        myIndicator.setText(VcsBundle.message("progress.text.synchronizing.files"));
      }

      doRefresh(myProject, changesToRefresh);

      AbstractVcsHelper.getInstance(myProject)
          .showErrors(myExceptions, VcsBundle.message("changes.action.rollback.text"));
    }
Exemplo n.º 2
0
 private void deleteAddedFilesLocally(final List<Change> changes) {
   if (myIndicator != null) {
     myIndicator.setText("Deleting added files locally...");
     myIndicator.setFraction(0);
   }
   final int changesSize = changes.size();
   for (int i = 0; i < changesSize; i++) {
     final Change c = changes.get(i);
     if (c.getType() == Change.Type.NEW) {
       ContentRevision rev = c.getAfterRevision();
       assert rev != null;
       final File ioFile = rev.getFile().getIOFile();
       if (myIndicator != null) {
         myIndicator.setText2(ioFile.getAbsolutePath());
         myIndicator.setFraction(((double) i) / changesSize);
       }
       FileUtil.delete(ioFile);
     }
   }
   if (myIndicator != null) {
     myIndicator.setText2("");
   }
 }