void () { List<FilePath> filesToConfirmDeletion = myProcessor.acquireDeletedFiles(); // skip files which are not under Mercurial skipNotUnderHg(filesToConfirmDeletion); skipVcsIgnored(filesToConfirmDeletion); List<FilePath> filesToDelete = new ArrayList<>(); // newly added files (which were added to the repo but never committed) should be removed from the VCS, // but without user confirmation. for (Iterator<FilePath> it = filesToConfirmDeletion.iterator(); it.hasNext(); ) { FilePath filePath = it.next(); Change fileChange = ChangeListManager.getInstance(myProject).getChange(filePath); if (fileChange != null && fileChange.getFileStatus().equals(FileStatus.ADDED)) { filesToDelete.add(filePath); it.remove(); } } new Task.Backgroundable(myProject, HgBundle.message("hg4idea.remove.progress"), false) { @Override public void run(@NotNull ProgressIndicator indicator) { // confirm removal from the VCS if needed if (myRemoveOption.getValue() != VcsShowConfirmationOption.Value.DO_NOTHING_SILENTLY) { if (myRemoveOption.getValue() == VcsShowConfirmationOption.Value.DO_ACTION_SILENTLY || filesToConfirmDeletion.isEmpty()) { filesToDelete.addAll(filesToConfirmDeletion); } else { final AtomicReference<Collection<FilePath>> filePaths = new AtomicReference<>(); ApplicationManager.getApplication().invokeAndWait(() -> filePaths.set(selectFilePathsToDelete(filesToConfirmDeletion))); if (filePaths.get() != null) { filesToDelete.addAll(filePaths.get()); } } } if (!filesToDelete.isEmpty()) { performDeletion(filesToDelete); } } }.queue(); }