void (@NotNull ProgressIndicator pi) { for (Map.Entry<VirtualFile, Collection<VirtualFile>> e : sortedFiles.entrySet()) { VirtualFile repo = e.getKey(); final Collection<VirtualFile> files = e.getValue(); pi.setText(repo.getPresentableUrl()); Collection<VirtualFile> untrackedForRepo = new HgStatusCommand.Builder(false).unknown(true).removed(true).build(myProject) .getFiles(repo, new ArrayList<>(files)); untrackedFiles.addAll(untrackedForRepo); } addedFiles.retainAll(untrackedFiles); // select files to add if there is something to select if (!addedFiles.isEmpty() || !copyFromMap.isEmpty()) { performAddingWithConfirmation(addedFiles, copyFromMap); } }