in src/org/jetbrains/tfsIntegration/core/TFSFileListener.java [152:274]
protected void executeDelete() {
// choose roots
// revert all pending schedules for addition recursively
// throw out all the unversioned items
AllDeletedFiles files = myProcessor.acquireAllDeletedFiles();
List<FilePath> deletedFiles = files.deletedFiles;
deletedFiles.addAll(files.deletedWithoutConfirmFiles);
try {
WorkstationHelper.processByWorkspaces(deletedFiles, false, myProject, new WorkstationHelper.VoidProcessDelegate() {
@Override
public void executeRequest(final WorkspaceInfo workspace, final List<ItemPath> paths) throws TfsException {
RootsCollection.ItemPathRootsCollection roots = new RootsCollection.ItemPathRootsCollection(paths);
final Collection<PendingChange> pendingChanges = workspace.getServer().getVCS()
.queryPendingSetsByLocalPaths(workspace.getName(), workspace.getOwnerName(), roots, RecursionType.Full, myProject,
TFSBundle.message("loading.changes"));
final List<String> revertImmediately = new ArrayList<>();
final List<ItemPath> pathsToProcess = new ArrayList<>(paths);
for (PendingChange pendingChange : pendingChanges) {
final ChangeTypeMask changeType = new ChangeTypeMask(pendingChange.getChg());
if (changeType.containsAny(ChangeType_type0.Add, ChangeType_type0.Undelete)) {
// TODO: assert that only Edit, Encoding can be here
revertImmediately.add(pendingChange.getItem());
final FilePath localPath =
VersionControlPath.getFilePath(pendingChange.getLocal(), pendingChange.getType() == ItemType.Folder);
deletedFiles.remove(localPath);
final ItemPath itemPath = new ItemPath(localPath, pendingChange.getItem());
pathsToProcess.remove(itemPath);
}
}
UndoPendingChanges.UndoPendingChangesResult undoResult =
UndoPendingChanges.execute(myProject, workspace, revertImmediately, true, ApplyProgress.EMPTY, false);
if (!undoResult.errors.isEmpty()) {
// TODO list -> collection
AbstractVcsHelper.getInstance(myProject).showErrors(new ArrayList<>(undoResult.errors), TFSVcs.TFS_NAME);
}
StatusProvider.visitByStatus(workspace, pathsToProcess, false, null, new StatusVisitor() {
@Override
public void scheduledForAddition(final @NotNull FilePath localPath,
final boolean localItemExists,
final @NotNull ServerStatus serverStatus) {
TFSVcs.error("Cannot revert an item scheduled for addition: " + localPath.getPresentableUrl());
}
@Override
public void unversioned(final @NotNull FilePath localPath,
final boolean localItemExists,
final @NotNull ServerStatus serverStatus) {
deletedFiles.remove(localPath);
}
@Override
public void deleted(final @NotNull FilePath localPath,
final boolean localItemExists,
final @NotNull ServerStatus serverStatus) {
deletedFiles.remove(localPath);
}
@Override
public void scheduledForDeletion(final @NotNull FilePath localPath,
final boolean localItemExists,
final @NotNull ServerStatus serverStatus) {
deletedFiles.remove(localPath);
}
@Override
public void checkedOutForEdit(final @NotNull FilePath localPath,
final boolean localItemExists,
final @NotNull ServerStatus serverStatus) {
// keep for further processing
}
@Override
public void outOfDate(final @NotNull FilePath localPath,
final boolean localItemExists,
final @NotNull ServerStatus serverStatus) throws TfsException {
// keep for further processing
}
@Override
public void upToDate(final @NotNull FilePath localPath, final boolean localItemExists, final @NotNull ServerStatus serverStatus)
throws TfsException {
// keep for further processing
}
@Override
public void renamed(final @NotNull FilePath localPath, final boolean localItemExists, final @NotNull ServerStatus serverStatus)
throws TfsException {
// keep for further processing
}
@Override
public void renamedCheckedOut(final @NotNull FilePath localPath,
final boolean localItemExists,
final @NotNull ServerStatus serverStatus) throws TfsException {
// keep for further processing
}
@Override
public void undeleted(final @NotNull FilePath localPath,
final boolean localItemExists,
final @NotNull ServerStatus serverStatus) throws TfsException {
TFSVcs.error("Cannot revert undeleted: " + localPath.getPresentableUrl());
}
}, myProject);
}
});
}
catch (TfsException e) {
AbstractVcsHelper.getInstance(myProject).showError(new VcsException(e), TFSVcs.TFS_NAME);
}
if (!deletedFiles.isEmpty()) {
performDeletion(deletedFiles);
}
}