public static UndoPendingChangesResult execute()

in src/org/jetbrains/tfsIntegration/core/tfs/operations/UndoPendingChanges.java [49:100]


  public static UndoPendingChangesResult execute(final Project project,
                                                 final WorkspaceInfo workspace,
                                                 final Collection<String> serverPaths,
                                                 final boolean forbidDownload,
                                                 @NotNull ApplyProgress progress,
                                                 boolean tolerateNoChangesFailure) {
    if (serverPaths.isEmpty()) {
      return new UndoPendingChangesResult(Collections.emptyMap(), Collections.emptyList());
    }

    // undo changes
    try {
      ResultWithFailures<GetOperation> result =
        workspace.getServer().getVCS()
          .undoPendingChanges(workspace.getName(), workspace.getOwnerName(), serverPaths, project, TFSBundle.message("reverting"));

      Collection<Failure> failures = result.getFailures();
      if (tolerateNoChangesFailure) {
        for (Iterator<Failure> i = failures.iterator(); i.hasNext();) {
          if (ITEM_NOT_CHECKED_OUT_FAILURE.equals(i.next().getCode())) {
            i.remove();
          }
        }
      }

      Collection<VcsException> errors = new ArrayList<>(TfsUtil.getVcsExceptions(failures));

      // TODO fill renamed paths map in ApplyGetOperations
      Map<ItemPath, ItemPath> undonePaths = new HashMap<>();
      for (GetOperation getOperation : result.getResult()) {
        if (getOperation.getSlocal() != null && getOperation.getTlocal() != null) {
          @NotNull FilePath sourcePath =
            VersionControlPath.getFilePath(getOperation.getSlocal(), getOperation.getType() == ItemType.Folder);
          @NotNull FilePath targetPath =
            VersionControlPath.getFilePath(getOperation.getTlocal(), getOperation.getType() == ItemType.Folder);
          undonePaths.put(new ItemPath(sourcePath, workspace.findServerPathsByLocalPath(sourcePath, false, project).iterator().next()),
                          new ItemPath(targetPath, workspace.findServerPathsByLocalPath(targetPath, false, project).iterator().next()));
        }
      }


      final ApplyGetOperations.DownloadMode downloadMode =
        forbidDownload ? ApplyGetOperations.DownloadMode.FORBID : ApplyGetOperations.DownloadMode.FORCE;
      final Collection<VcsException> applyingErrors =
        ApplyGetOperations.execute(project, workspace, result.getResult(), progress, null, downloadMode);
      errors.addAll(applyingErrors);
      return new UndoPendingChangesResult(undonePaths, errors);
    }
    catch (TfsException e) {
      return new UndoPendingChangesResult(Collections.emptyMap(), Collections.singletonList(new VcsException(e)));
    }
  }