public UpdateSession updateDirectories()

in src/org/jetbrains/tfsIntegration/core/TFSUpdateEnvironment.java [55:137]


  public UpdateSession updateDirectories(@NotNull final FilePath[] contentRoots,
                                         final UpdatedFiles updatedFiles,
                                         final ProgressIndicator progressIndicator,
                                         @NotNull final Ref<SequentialUpdatesContext> context) throws ProcessCanceledException {
    final List<VcsException> exceptions = new ArrayList<>();
    TFSProgressUtil.setProgressText(progressIndicator, "Request update information");
    try {
      final Map<WorkspaceInfo, Collection<Conflict>> workspace2Conflicts = new HashMap<>();
      List<FilePath> orphanPaths =
        WorkstationHelper.processByWorkspaces(Arrays.asList(contentRoots), true, myVcs.getProject(),
                                              new WorkstationHelper.VoidProcessDelegate() {
          @Override
          public void executeRequest(final WorkspaceInfo workspace, final List<ItemPath> paths) throws TfsException {
            VersionSpecBase version = LatestVersionSpec.INSTANCE;
            RecursionType recursionType = RecursionType.Full;
            TFSProjectConfiguration configuration = TFSProjectConfiguration.getInstance(myVcs.getProject());
            if (configuration != null) {
              version = configuration.getUpdateWorkspaceInfo(workspace).getVersion();
              recursionType = configuration.getState().UPDATE_RECURSIVELY ? RecursionType.Full : RecursionType.None;
            }

            // 1. query get operations for contentRoots - to let server know which version we need to report corresponding server conflicts
            List<VersionControlServer.GetRequestParams> requests = new ArrayList<>(paths.size());
            for (ItemPath path : paths) {
              requests.add(new VersionControlServer.GetRequestParams(path.getServerPath(), recursionType, version));
              TFSProgressUtil.checkCanceled(progressIndicator);
            }

            List<GetOperation> operations = workspace.getServer().getVCS()
              .get(workspace.getName(), workspace.getOwnerName(), requests, myVcs.getProject(),
                   TFSBundle.message("preparing.for.download"));
            // execute GetOperation-s, conflicting ones will be skipped
            final Collection<VcsException> applyErrors = ApplyGetOperations
              .execute(myVcs.getProject(), workspace, operations, new ApplyProgress.ProgressIndicatorWrapper(progressIndicator),
                       updatedFiles, ApplyGetOperations.DownloadMode.ALLOW);
            exceptions.addAll(applyErrors);

            Collection<Conflict> conflicts =
              workspace.getServer().getVCS()
                .queryConflicts(workspace.getName(), workspace.getOwnerName(), paths, RecursionType.Full, myVcs.getProject(),
                                TFSBundle.message("loading.conflicts"));

            final Collection<Conflict> unresolvedConflicts = ResolveConflictHelper.getUnresolvedConflicts(conflicts);
            if (!unresolvedConflicts.isEmpty()) {
              workspace2Conflicts.put(workspace, unresolvedConflicts);
            }
          }
        });

      if (!workspace2Conflicts.isEmpty()) {
        ResolveConflictHelper resolveConflictHelper = new ResolveConflictHelper(myVcs.getProject(), workspace2Conflicts, updatedFiles);
        ConflictsEnvironment.getConflictsHandler().resolveConflicts(resolveConflictHelper);
      }

      for (FilePath orphanPath : orphanPaths) {
        updatedFiles.getGroupById(FileGroup.UNKNOWN_ID).add(orphanPath.getPresentableUrl(), TFSVcs.getKey(), null);
      }
    }
    catch (TfsException e) {
      exceptions.add(new VcsException(e));
    }

    // TODO content roots can be renamed while executing
    TfsFileUtil.refreshAndInvalidate(myVcs.getProject(), contentRoots, false);

    return new UpdateSession() {
      @Override
      @NotNull
      public List<VcsException> getExceptions() {
        return exceptions;
      }

      @Override
      public void onRefreshFilesCompleted() {
        myVcs.fireRevisionChanged();
      }

      @Override
      public boolean isCanceled() {
        return false;
      }
    };
  }