Search in sources :

Example 56 with FilePath

use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.

the class GetFileFromRepositoryAction method getCvsHandler.

protected CvsHandler getCvsHandler(CvsContext context) {
    CvsLightweightFile[] cvsLightweightFiles = context.getSelectedLightweightFiles();
    Project project = context.getProject();
    if (cvsLightweightFiles != null) {
        boolean makeNewFilesReadOnly = project != null && CvsConfiguration.getInstance(project).MAKE_NEW_FILES_READONLY;
        return CommandCvsHandler.createGetFileFromRepositoryHandler(cvsLightweightFiles, makeNewFilesReadOnly);
    }
    final FilePath[] filePaths = context.getSelectedFilePaths();
    if (filePaths != null) {
        CvsConfiguration cvsConfiguration = CvsConfiguration.getInstance(project);
        // do not use -j's
        final UpdateSettingsOnCvsConfiguration updateSettings = new UpdateSettingsOnCvsConfiguration(cvsConfiguration, cvsConfiguration.CLEAN_COPY, cvsConfiguration.RESET_STICKY);
        return CommandCvsHandler.createUpdateHandler(filePaths, updateSettings, project, UpdatedFiles.create());
    }
    return CvsHandler.NULL;
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) Project(com.intellij.openapi.project.Project) CvsConfiguration(com.intellij.cvsSupport2.config.CvsConfiguration) UpdateSettingsOnCvsConfiguration(com.intellij.cvsSupport2.actions.update.UpdateSettingsOnCvsConfiguration) CvsLightweightFile(com.intellij.cvsSupport2.actions.cvsContext.CvsLightweightFile) UpdateSettingsOnCvsConfiguration(com.intellij.cvsSupport2.actions.update.UpdateSettingsOnCvsConfiguration)

Example 57 with FilePath

use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.

the class RemoveLocallyFileOrDirectoryAction method getCvsHandler.

private static CvsHandler getCvsHandler(final Project project, final Collection<File> filesToRemove, final boolean showDialog) {
    final ArrayList<File> files = new ArrayList<>();
    for (final File file : filesToRemove) {
        if (CvsUtil.fileIsLocallyAdded(file)) {
            CvsUtil.removeEntryFor(file);
        } else {
            files.add(file);
        }
    }
    if (files.isEmpty())
        return CvsHandler.NULL;
    Collection<FilePath> filesToBeRemoved = filesToFilePaths(files);
    if (showDialog) {
        final AbstractVcsHelper vcsHelper = AbstractVcsHelper.getInstance(project);
        filesToBeRemoved = vcsHelper.selectFilePathsToProcess(filesToFilePaths(files), CvsBundle.message("dialog.title.delete.files.from.cvs"), null, CvsBundle.message("dialog.title.delete.file.from.cvs"), CvsBundle.message("confirmation.text.delete.file.from.cvs"), VcsShowConfirmationOption.STATIC_SHOW_CONFIRMATION, CvsBundle.message("button.text.delete.from.cvs"), CommonBundle.getCancelButtonText());
        if (filesToBeRemoved == null || filesToBeRemoved.isEmpty())
            return CvsHandler.NULL;
    }
    return CommandCvsHandler.createRemoveFilesHandler(project, ChangesUtil.filePathsToFiles(filesToBeRemoved));
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) AbstractVcsHelper(com.intellij.openapi.vcs.AbstractVcsHelper) ArrayList(java.util.ArrayList) File(java.io.File)

Example 58 with FilePath

use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.

the class CvsAnnotationProvider method annotate.

public FileAnnotation annotate(VirtualFile cvsVirtualFile, String revision, CvsEnvironment environment) throws VcsException {
    // the VirtualFile has a full path if annotate is called from history (when we have a real file on disk),
    // and has the path equal to a CVS module name if annotate is called from the CVS repository browser
    // (when there's no real path)
    boolean hasLocalFile = false;
    File cvsFile = new File(cvsVirtualFile.getPath());
    if (cvsFile.isAbsolute()) {
        hasLocalFile = true;
        cvsFile = new File(CvsUtil.getModuleName(cvsVirtualFile));
    }
    final boolean binary = annotateBinary(cvsVirtualFile, environment);
    final AnnotateOperation annotateOperation = executeOperation(cvsFile, revision, environment, binary, true);
    final Annotation[] lineAnnotations = annotateOperation.getLineAnnotations();
    final List<VcsFileRevision> revisions;
    if (hasLocalFile) {
        final FilePath filePath = VcsContextFactory.SERVICE.getInstance().createFilePathOn(cvsVirtualFile);
        revisions = myCvsHistoryProvider.createRevisions(filePath);
        // in annotation cvs returns only 8 symbols of username
        // try to find usernames in history and use them
        adjustAnnotation(revisions, lineAnnotations);
    } else {
        // imitation
        revisions = new ArrayList<>();
        final Set<String> usedRevisions = new HashSet<>();
        for (Annotation annotation : lineAnnotations) {
            if (!usedRevisions.contains(annotation.getRevision())) {
                revisions.add(new RevisionPresentation(annotation.getRevision(), annotation.getUserName(), annotation.getDate()));
                usedRevisions.add(annotation.getRevision());
            }
        }
    }
    return new CvsFileAnnotation(annotateOperation.getContent(), lineAnnotations, revisions, cvsVirtualFile, revision, myProject);
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) AnnotateOperation(com.intellij.cvsSupport2.cvsoperations.cvsAnnotate.AnnotateOperation) FileAnnotation(com.intellij.openapi.vcs.annotate.FileAnnotation) Annotation(com.intellij.cvsSupport2.cvsoperations.cvsAnnotate.Annotation) VcsFileRevision(com.intellij.openapi.vcs.history.VcsFileRevision) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 59 with FilePath

use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.

the class BranchAction method getCvsHandler.

protected CvsHandler getCvsHandler(CvsContext context) {
    final FilePath[] selectedFiles = context.getSelectedFilePaths();
    final Project project = context.getProject();
    final CreateTagDialog dialog = new CreateTagDialog(selectedFiles, project, false);
    if (!dialog.showAndGet()) {
        return CvsHandler.NULL;
    }
    final boolean makeNewFilesReadOnly = CvsConfiguration.getInstance(project).MAKE_NEW_FILES_READONLY;
    return CommandCvsHandler.createBranchHandler(selectedFiles, dialog.getTagName(), dialog.switchToThisBranch(), dialog.getOverrideExisting(), makeNewFilesReadOnly, project);
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) Project(com.intellij.openapi.project.Project) CreateTagDialog(com.intellij.cvsSupport2.cvsoperations.cvsTagOrBranch.ui.CreateTagDialog)

Example 60 with FilePath

use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.

the class CvsCheckinEnvironment method commit.

public List<VcsException> commit(List<Change> changes, String preparedComment, @NotNull NullableFunction<Object, Object> parametersHolder, Set<String> feedback) {
    final Collection<FilePath> filesList = ChangesUtil.getPaths(changes);
    FilePath[] files = filesList.toArray(new FilePath[filesList.size()]);
    final CvsOperationExecutor executor = new CvsOperationExecutor(myProject);
    executor.setShowErrors(false);
    final List<File> dirsToPrune = new ArrayList<>();
    for (Change c : changes) {
        if (c.getType() == Change.Type.DELETED) {
            final ContentRevision contentRevision = c.getBeforeRevision();
            assert contentRevision != null;
            final FilePath path = contentRevision.getFile();
            final FilePath parentPath = path.getParentPath();
            if (parentPath != null) {
                dirsToPrune.add(parentPath.getIOFile());
            }
        }
    }
    final CvsConfiguration cvsConfiguration = CvsConfiguration.getInstance(myProject);
    CvsHandler handler = CommandCvsHandler.createCommitHandler(files, preparedComment, CvsBundle.message("operation.name.commit.file", files.length), cvsConfiguration.MAKE_NEW_FILES_READONLY, myProject, cvsConfiguration.TAG_AFTER_PROJECT_COMMIT, cvsConfiguration.TAG_AFTER_PROJECT_COMMIT_NAME, dirsToPrune);
    executor.performActionSync(handler, CvsOperationExecutorCallback.EMPTY);
    return executor.getResult().getErrorsAndWarnings();
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) CvsConfiguration(com.intellij.cvsSupport2.config.CvsConfiguration) CommandCvsHandler(com.intellij.cvsSupport2.cvshandlers.CommandCvsHandler) CvsHandler(com.intellij.cvsSupport2.cvshandlers.CvsHandler) CvsOperationExecutor(com.intellij.cvsSupport2.cvsExecution.CvsOperationExecutor) ContentRevision(com.intellij.openapi.vcs.changes.ContentRevision) Change(com.intellij.openapi.vcs.changes.Change) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Aggregations

FilePath (com.intellij.openapi.vcs.FilePath)167 VirtualFile (com.intellij.openapi.vfs.VirtualFile)68 NotNull (org.jetbrains.annotations.NotNull)43 VcsException (com.intellij.openapi.vcs.VcsException)34 File (java.io.File)30 Change (com.intellij.openapi.vcs.changes.Change)26 Nullable (org.jetbrains.annotations.Nullable)22 Project (com.intellij.openapi.project.Project)20 ContentRevision (com.intellij.openapi.vcs.changes.ContentRevision)15 VcsFileRevision (com.intellij.openapi.vcs.history.VcsFileRevision)13 FileStatus (com.intellij.openapi.vcs.FileStatus)10 AbstractVcs (com.intellij.openapi.vcs.AbstractVcs)8 GitRepository (git4idea.repo.GitRepository)7 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)6 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 List (java.util.List)6 Test (org.junit.Test)6 StringUtil (com.intellij.openapi.util.text.StringUtil)5 Logger (com.intellij.openapi.diagnostic.Logger)4