in src/org/jetbrains/tfsIntegration/core/tfs/operations/ScheduleForDeletion.java [35:150]
public static Collection<VcsException> execute(Project project, WorkspaceInfo workspace, List<ItemPath> paths) {
// choose roots
// recursively undo pending changes except schedule for deletion => map: modified_name->original_name
// schedule roots for deletion using their original names (+updateLocalVersion)
Collection<VcsException> errors = new ArrayList<>();
try {
RootsCollection.ItemPathRootsCollection roots = new RootsCollection.ItemPathRootsCollection(paths);
final Collection<PendingChange> pendingChanges = workspace.getServer().getVCS()
.queryPendingSetsByLocalPaths(workspace.getName(), workspace.getOwnerName(), roots, RecursionType.Full, project,
TFSBundle.message("loading.changes"));
Collection<String> revert = new ArrayList<>();
for (PendingChange pendingChange : pendingChanges) {
ChangeTypeMask change = new ChangeTypeMask(pendingChange.getChg());
if (!change.contains(ChangeType_type0.Delete)) {
// TODO assert for possible change types here
revert.add(pendingChange.getItem());
}
}
final UndoPendingChanges.UndoPendingChangesResult undoResult =
UndoPendingChanges.execute(project, workspace, revert, true, ApplyProgress.EMPTY, false);
errors.addAll(undoResult.errors);
List<ItemPath> undoneRoots = new ArrayList<>(roots.size());
for (ItemPath originalRoot : roots) {
ItemPath undoneRoot = undoResult.undonePaths.get(originalRoot);
undoneRoots.add(undoneRoot != null ? undoneRoot : originalRoot);
}
final List<FilePath> scheduleForDeletion = new ArrayList<>();
StatusProvider.visitByStatus(workspace, undoneRoots, false, null, new StatusVisitor() {
@Override
public void unversioned(final @NotNull FilePath localPath, final boolean localItemExists, final @NotNull ServerStatus serverStatus)
throws TfsException {
// ignore
}
@Override
public void deleted(final @NotNull FilePath localPath, final boolean localItemExists, final @NotNull ServerStatus serverStatus) {
// ignore
}
@Override
public void checkedOutForEdit(final @NotNull FilePath localPath,
final boolean localItemExists,
final @NotNull ServerStatus serverStatus) throws TfsException {
TFSVcs.error("Unexpected status " + serverStatus.getClass().getName() + " for " + localPath.getPresentableUrl());
}
@Override
public void scheduledForAddition(final @NotNull FilePath localPath,
final boolean localItemExists,
final @NotNull ServerStatus serverStatus) {
TFSVcs.error("Unexpected status " + serverStatus.getClass().getName() + " for " + localPath.getPresentableUrl());
}
@Override
public void scheduledForDeletion(final @NotNull FilePath localPath,
final boolean localItemExists,
final @NotNull ServerStatus serverStatus) {
TFSVcs.error("Unexpected status " + serverStatus.getClass().getName() + " for " + localPath.getPresentableUrl());
}
@Override
public void outOfDate(final @NotNull FilePath localPath, final boolean localItemExists, final @NotNull ServerStatus serverStatus)
throws TfsException {
scheduleForDeletion.add(localPath);
}
@Override
public void upToDate(final @NotNull FilePath localPath, final boolean localItemExists, final @NotNull ServerStatus serverStatus)
throws TfsException {
scheduleForDeletion.add(localPath);
}
@Override
public void renamed(final @NotNull FilePath localPath, final boolean localItemExists, final @NotNull ServerStatus serverStatus)
throws TfsException {
TFSVcs.error("Unexpected status " + serverStatus.getClass().getName() + " for " + localPath.getPresentableUrl());
}
@Override
public void renamedCheckedOut(final @NotNull FilePath localPath,
final boolean localItemExists,
final @NotNull ServerStatus serverStatus) throws TfsException {
TFSVcs.error("Unexpected status " + serverStatus.getClass().getName() + " for " + localPath.getPresentableUrl());
}
@Override
public void undeleted(final @NotNull FilePath localPath, final boolean localItemExists, final @NotNull ServerStatus serverStatus)
throws TfsException {
TFSVcs.error("Unexpected status " + serverStatus.getClass().getName() + " for " + localPath.getPresentableUrl());
}
}, project);
ResultWithFailures<GetOperation> schedulingForDeletionResults = workspace.getServer().getVCS()
.scheduleForDeletionAndUpateLocalVersion(workspace.getName(), workspace.getOwnerName(), scheduleForDeletion, project,
TFSBundle.message("scheduling.for.deletion"));
errors.addAll(TfsUtil.getVcsExceptions(schedulingForDeletionResults.getFailures()));
for (GetOperation getOperation : schedulingForDeletionResults.getResult()) {
TfsFileUtil
.markFileDirty(project, VersionControlPath.getFilePath(getOperation.getSlocal(), getOperation.getType() == ItemType.Folder));
}
}
catch (TfsException e) {
errors.add(new VcsException(e));
}
return errors;
}