Search in sources :

Example 1 with NodeKind

use of org.jetbrains.idea.svn.api.NodeKind in project intellij-community by JetBrains.

the class SvnFileSystemListener method createItem.

/**
   * 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, ioDir) && !pendingAdd) {
        return false;
    }
    final File targetFile = new File(ioDir, name);
    Status status = getFileStatus(vcs, targetFile);
    if (status == null || status.getContentsStatus() == StatusType.STATUS_NONE || status.getContentsStatus() == StatusType.STATUS_UNVERSIONED) {
        myAddedFiles.putValue(vcs.getProject(), new AddedFileInfo(dir, name, null, recursive));
        return false;
    } else if (status.is(StatusType.STATUS_MISSING)) {
        return false;
    } else if (status.is(StatusType.STATUS_DELETED)) {
        NodeKind kind = status.getKind();
        // kind differs.
        if (directory && !kind.isDirectory() || !directory && !kind.isFile()) {
            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 (VcsException e) {
            SVNFileUtil.deleteAll(targetFile, true);
            return false;
        }
    }
    return false;
}
Also used : Status(org.jetbrains.idea.svn.status.Status) NodeKind(org.jetbrains.idea.svn.api.NodeKind) VirtualFile(com.intellij.openapi.vfs.VirtualFile) ActionWithTempFile(com.intellij.vcsUtil.ActionWithTempFile) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile) File(java.io.File)

Aggregations

VfsUtilCore.virtualToIoFile (com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 ActionWithTempFile (com.intellij.vcsUtil.ActionWithTempFile)1 File (java.io.File)1 NodeKind (org.jetbrains.idea.svn.api.NodeKind)1 Status (org.jetbrains.idea.svn.status.Status)1