/**
   * add file or directory:
   *
   * <p>parent directory is: unversioned: do nothing, return false versioned: entry is: null: create
   * entry, schedule for addition missing: do nothing, return false deleted, 'do' mode: try to
   * create entry and it schedule for addition if kind is the same, otherwise do nothing, return
   * false. deleted: 'undo' mode: try to revert non-recursively, if kind is the same, otherwise do
   * nothing, return false. anything else: return false.
   */
  private boolean createItem(
      VirtualFile dir, String name, boolean directory, final boolean recursive) {
    SvnVcs vcs = getVCS(dir);
    if (vcs == null) {
      return false;
    }
    final VcsShowConfirmationOption.Value value = vcs.getAddConfirmation().getValue();
    if (VcsShowConfirmationOption.Value.DO_NOTHING_SILENTLY.equals(value)) return false;

    if (isUndo(vcs) && SvnUtil.isAdminDirectory(dir, name)) {
      return false;
    }
    File ioDir = getIOFile(dir);
    boolean pendingAdd = isPendingAdd(vcs.getProject(), dir);
    if (!SvnUtil.isSvnVersioned(vcs.getProject(), ioDir) && !pendingAdd) {
      return false;
    }
    final File targetFile = new File(ioDir, name);
    SVNStatus status = getFileStatus(vcs, targetFile);

    if (status == null
        || status.getContentsStatus() == SVNStatusType.STATUS_NONE
        || status.getContentsStatus() == SVNStatusType.STATUS_UNVERSIONED) {
      myAddedFiles.putValue(vcs.getProject(), new AddedFileInfo(dir, name, null, recursive));
      return false;
    } else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_MISSING)) {
      return false;
    } else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_DELETED)) {
      SVNNodeKind kind = status.getKind();
      // kind differs.
      if (directory && kind != SVNNodeKind.DIR || !directory && kind != SVNNodeKind.FILE) {
        return false;
      }
      try {
        if (isUndo(vcs)) {
          createRevertAction(vcs, targetFile, false).execute();
          return true;
        }
        myAddedFiles.putValue(vcs.getProject(), new AddedFileInfo(dir, name, null, recursive));
        return false;
      } catch (SVNException e) {
        SVNFileUtil.deleteAll(targetFile, true);
        return false;
      }
    }
    return false;
  }
Esempio n. 2
0
  /**
   * Method getStatus
   *
   * @param status
   * @return
   */
  public static char[] getStatus(SVNStatus status) {
    char[] s = {' ', ' ', ' ', ' ', ' ', ' ', ' '};

    // column 1 file status
    s[0] = status.getContentsStatus().getCode();
    // column 2 folder status
    s[1] = status.getPropertiesStatus().getCode();

    // column 3 lock status
    if (status.isLocked()) {
      s[2] = 'L';
    }

    // column 4 copy status
    if (status.isCopied()) {
      s[3] = '+';
    }

    // column 5 switched status
    if (status.isSwitched()) {
      s[4] = 'S';
    }

    // column 6 local lock status
    if (status.getLocalLock() != null) {
      s[5] = 'K';
    }

    // column 7 needs update
    if ((status.getRemotePropertiesStatus() != SVNStatusType.STATUS_NONE)
        || (status.getRemoteContentsStatus() != SVNStatusType.STATUS_NONE)) {
      s[6] = '*';
    }

    return s;
  }
Esempio n. 3
0
 public static boolean svnStatusIs(final SVNStatus status, @NotNull final SVNStatusType value) {
   return value.equals(status.getNodeStatus()) || value.equals(status.getContentsStatus());
 }