コード例 #1
0
  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"));
    }
  }
コード例 #2
0
  /**
   * delete file or directory (both 'undo' and 'do' modes) unversioned: do nothing, return false
   * obstructed: do nothing, return false external or wc root: do nothing, return false missing: do
   * nothing, return false
   *
   * <p>versioned: schedule for deletion, return true added: schedule for deletion (make
   * unversioned), return true copied, but not scheduled: schedule for deletion, return true
   * replaced: schedule for deletion, return true
   *
   * <p>deleted: do nothing, return true (strange)
   */
  public boolean delete(VirtualFile file) throws IOException {
    final SvnVcs vcs = getVCS(file);
    if (vcs != null && SvnUtil.isAdminDirectory(file)) {
      return true;
    }
    if (vcs == null) return false;
    final VcsShowConfirmationOption.Value value = vcs.getDeleteConfirmation().getValue();
    if (VcsShowConfirmationOption.Value.DO_NOTHING_SILENTLY.equals(value)) return false;

    final File ioFile = getIOFile(file);
    if (!SvnUtil.isSvnVersioned(vcs.getProject(), ioFile.getParentFile())) {
      return false;
    }
    if (SvnUtil.isWorkingCopyRoot(ioFile)) {
      return false;
    }

    SVNStatus status = getFileStatus(vcs, ioFile);

    if (status == null
        || SvnVcs.svnStatusIsUnversioned(status)
        || SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_OBSTRUCTED)
        || SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_MISSING)
        || SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_EXTERNAL)
        || SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_IGNORED)) {
      return false;
    } else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_DELETED)) {
      if (isUndo(vcs)) {
        moveToUndoStorage(file);
      }
      return true;
    } else {
      if (vcs != null) {
        if (isAboveSourceOfCopyOrMove(vcs.getProject(), ioFile)) {
          myDeletedFiles.putValue(vcs.getProject(), ioFile);
          return true;
        }
        if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_ADDED)) {
          try {
            createRevertAction(vcs, ioFile, false).execute();
          } catch (SVNException e) {
            // ignore
          }
        } else {
          myDeletedFiles.putValue(vcs.getProject(), ioFile);
          // packages deleted from disk should not be deleted from svn (IDEADEV-16066)
          if (file.isDirectory() || isUndo(vcs)) return true;
        }
      }
      return false;
    }
  }
コード例 #3
0
  private Collection<FilePath> promptAboutDeletion(
      List<Pair<FilePath, WorkingCopyFormat>> deletedFiles,
      SvnVcs vcs,
      VcsShowConfirmationOption.Value value,
      AbstractVcsHelper vcsHelper) {
    final Convertor<Pair<FilePath, WorkingCopyFormat>, FilePath> convertor =
        new Convertor<Pair<FilePath, WorkingCopyFormat>, FilePath>() {
          @Override
          public FilePath convert(Pair<FilePath, WorkingCopyFormat> o) {
            return o.getFirst();
          }
        };
    Collection<FilePath> filesToProcess;
    if (value == VcsShowConfirmationOption.Value.DO_ACTION_SILENTLY) {
      filesToProcess = ObjectsConvertor.convert(deletedFiles, convertor);
    } else {

      final String singleFilePrompt;
      if (deletedFiles.size() == 1 && deletedFiles.get(0).getFirst().isDirectory()) {
        singleFilePrompt =
            WorkingCopyFormat.ONE_DOT_SEVEN.equals(deletedFiles.get(0).getSecond())
                ? SvnBundle.getString("confirmation.text.delete.dir.17")
                : SvnBundle.getString("confirmation.text.delete.dir");
      } else {
        singleFilePrompt = SvnBundle.getString("confirmation.text.delete.file");
      }
      final Collection<FilePath> files =
          vcsHelper.selectFilePathsToProcess(
              ObjectsConvertor.convert(deletedFiles, convertor),
              SvnBundle.message("confirmation.title.delete.multiple.files"),
              null,
              SvnBundle.message("confirmation.title.delete.file"),
              singleFilePrompt,
              vcs.getDeleteConfirmation());
      filesToProcess = files == null ? null : new ArrayList<FilePath>(files);
    }
    return filesToProcess;
  }