private void processDeletedFiles(Project project) { final List<Pair<FilePath, WorkingCopyFormat>> deletedFiles = new ArrayList<Pair<FilePath, WorkingCopyFormat>>(); final Collection<FilePath> filesToProcess = new ArrayList<FilePath>(); List<VcsException> exceptions = new ArrayList<VcsException>(); final AbstractVcsHelper vcsHelper = AbstractVcsHelper.getInstance(project); try { fillDeletedFiles(project, deletedFiles, filesToProcess); if (deletedFiles.isEmpty() && filesToProcess.isEmpty() || myUndoingMove) return; SvnVcs vcs = SvnVcs.getInstance(project); final VcsShowConfirmationOption.Value value = vcs.getDeleteConfirmation().getValue(); if (value != VcsShowConfirmationOption.Value.DO_NOTHING_SILENTLY) { if (!deletedFiles.isEmpty()) { final Collection<FilePath> confirmed = promptAboutDeletion(deletedFiles, vcs, value, vcsHelper); if (confirmed != null) { filesToProcess.addAll(confirmed); } } if (filesToProcess != null && !filesToProcess.isEmpty()) { runInBackground( project, "Deleting files from Subversion", createDeleteRunnable(project, vcs, filesToProcess, exceptions)); } final List<FilePath> deletedFilesFiles = ObjectsConvertor.convert( deletedFiles, new Convertor<Pair<FilePath, WorkingCopyFormat>, FilePath>() { @Override public FilePath convert(Pair<FilePath, WorkingCopyFormat> o) { return o.getFirst(); } }); for (FilePath file : deletedFilesFiles) { final FilePath parent = file.getParentPath(); if (parent != null) { myFilesToRefresh.add(parent.getVirtualFile()); } } if (filesToProcess != null) { deletedFilesFiles.removeAll(filesToProcess); } for (FilePath file : deletedFilesFiles) { FileUtil.delete(file.getIOFile()); } } } catch (SVNException e) { exceptions.add(new VcsException(e)); } if (!exceptions.isEmpty()) { vcsHelper.showErrors(exceptions, SvnBundle.message("delete.files.errors.title")); } }
private static void filterOutInvalid(final Collection<VirtualFile> files) { for (Iterator<VirtualFile> iterator = files.iterator(); iterator.hasNext(); ) { final VirtualFile file = iterator.next(); if (!file.isValid() || !file.exists()) { LOG.info("Refresh root is not valid: " + file.getPath()); iterator.remove(); } } }
private void processAddedFiles(Project project) { SvnVcs vcs = SvnVcs.getInstance(project); List<VirtualFile> addedVFiles = new ArrayList<VirtualFile>(); Map<VirtualFile, File> copyFromMap = new HashMap<VirtualFile, File>(); final Set<VirtualFile> recursiveItems = new HashSet<VirtualFile>(); fillAddedFiles(project, vcs, addedVFiles, copyFromMap, recursiveItems); if (addedVFiles.isEmpty()) return; final VcsShowConfirmationOption.Value value = vcs.getAddConfirmation().getValue(); if (value != VcsShowConfirmationOption.Value.DO_NOTHING_SILENTLY) { final AbstractVcsHelper vcsHelper = AbstractVcsHelper.getInstance(project); final Collection<VirtualFile> filesToProcess = promptAboutAddition(vcs, addedVFiles, value, vcsHelper); if (filesToProcess != null && !filesToProcess.isEmpty()) { final List<VcsException> exceptions = new ArrayList<VcsException>(); runInBackground( project, "Adding files to Subversion", createAdditionRunnable(project, vcs, copyFromMap, filesToProcess, exceptions)); if (!exceptions.isEmpty()) { vcsHelper.showErrors(exceptions, SvnBundle.message("add.files.errors.title")); } } } }
private void checkOverwrites(final Project project) { final Collection<AddedFileInfo> addedFileInfos = myAddedFiles.get(project); final Collection<File> deletedFiles = myDeletedFiles.get(project); if (addedFileInfos.isEmpty() || deletedFiles.isEmpty()) return; final Iterator<AddedFileInfo> iterator = addedFileInfos.iterator(); while (iterator.hasNext()) { AddedFileInfo addedFileInfo = iterator.next(); final File ioFile = new File(addedFileInfo.myDir.getPath(), addedFileInfo.myName); if (deletedFiles.remove(ioFile)) { iterator.remove(); } } }
private void fillDeletedFiles( Project project, List<Pair<FilePath, WorkingCopyFormat>> deletedFiles, Collection<FilePath> deleteAnyway) throws SVNException { final SvnVcs vcs = SvnVcs.getInstance(project); final Collection<File> files = myDeletedFiles.remove(project); for (final File file : files) { final SVNStatus status = new RepeatSvnActionThroughBusy() { @Override protected void executeImpl() throws SVNException { myT = vcs.getFactory(file).createStatusClient().doStatus(file, false); } }.compute(); boolean isAdded = SVNStatusType.STATUS_ADDED.equals(status.getNodeStatus()); final FilePath filePath = VcsContextFactory.SERVICE.getInstance().createFilePathOn(file); if (isAdded) { deleteAnyway.add(filePath); } else { deletedFiles.add(Pair.create(filePath, vcs.getWorkingCopyFormat(file))); } } }