Search in sources :

Example 11 with CvsHandler

use of com.intellij.cvsSupport2.cvshandlers.CvsHandler in project intellij-community by JetBrains.

the class CommandCvsHandler method createRestoreFileHandler.

public static CvsHandler createRestoreFileHandler(final VirtualFile parent, String name, boolean makeNewFilesReadOnly) {
    final File ioFile = new File(VfsUtilCore.virtualToIoFile(parent), name);
    final Entry entry = CvsEntriesManager.getInstance().getEntryFor(parent, name);
    final String revision = getRevision(entry);
    final CheckoutFileOperation operation = new CheckoutFileOperation(parent, new SimpleRevision(revision), name, makeNewFilesReadOnly);
    final CommandCvsHandler cvsHandler = new CommandCvsHandler(CvsBundle.message("operation.name.restore"), operation, FileSetToBeUpdated.EMPTY);
    operation.addFinishAction(() -> {
        final List<VcsException> errors = cvsHandler.getErrors();
        if (errors != null && !errors.isEmpty())
            return;
        if (entry != null) {
            entry.setRevision(revision);
            entry.setConflict(CvsUtil.formatDate(new Date(ioFile.lastModified())));
            try {
                CvsUtil.saveEntryForFile(ioFile, entry);
            } catch (IOException e) {
                LOG.error(e);
            }
            CvsEntriesManager.getInstance().clearCachedEntriesFor(parent);
        }
    });
    return cvsHandler;
}
Also used : Entry(org.netbeans.lib.cvsclient.admin.Entry) CheckoutFileOperation(com.intellij.cvsSupport2.cvsoperations.cvsCheckOut.CheckoutFileOperation) VcsException(com.intellij.openapi.vcs.VcsException) IOException(java.io.IOException) VirtualFile(com.intellij.openapi.vfs.VirtualFile) CvsLightweightFile(com.intellij.cvsSupport2.actions.cvsContext.CvsLightweightFile) File(java.io.File) SimpleRevision(com.intellij.cvsSupport2.cvsoperations.dateOrRevision.SimpleRevision)

Example 12 with CvsHandler

use of com.intellij.cvsSupport2.cvshandlers.CvsHandler in project intellij-community by JetBrains.

the class CommandCvsHandler method createEditHandler.

public static CvsHandler createEditHandler(VirtualFile[] selectedFiles, boolean isReservedEdit) {
    final EditOperation operation = new EditOperation(isReservedEdit);
    operation.addFiles(selectedFiles);
    return new CommandCvsHandler(CvsBundle.message("action.name.edit"), operation, FileSetToBeUpdated.selectedFiles(selectedFiles));
}
Also used : EditOperation(com.intellij.cvsSupport2.cvsoperations.cvsEdit.EditOperation)

Example 13 with CvsHandler

use of com.intellij.cvsSupport2.cvshandlers.CvsHandler in project intellij-community by JetBrains.

the class CommandCvsHandler method createGetFileFromRepositoryHandler.

public static CvsHandler createGetFileFromRepositoryHandler(CvsLightweightFile[] cvsLightweightFiles, boolean makeNewFilesReadOnly) {
    final CompositeOperation compositeOperation = new CompositeOperation();
    final CvsEntriesManager entriesManager = CvsEntriesManager.getInstance();
    for (CvsLightweightFile cvsLightweightFile : cvsLightweightFiles) {
        final File root = cvsLightweightFile.getRoot();
        File workingDirectory = root;
        if (workingDirectory == null)
            continue;
        if (cvsLightweightFile.getLocalFile().getParentFile().equals(workingDirectory)) {
            workingDirectory = workingDirectory.getParentFile();
        }
        final String alternativeCheckoutPath = getAlternativeCheckoutPath(cvsLightweightFile, workingDirectory);
        final CheckoutProjectOperation checkoutFileOperation = new CheckoutProjectOperation(new String[] { cvsLightweightFile.getModuleName() }, entriesManager.getCvsConnectionSettingsFor(root), makeNewFilesReadOnly, workingDirectory, alternativeCheckoutPath, true, null);
        compositeOperation.addOperation(checkoutFileOperation);
    }
    return new CommandCvsHandler(CvsBundle.message("action.name.get.file.from.repository"), compositeOperation, FileSetToBeUpdated.allFiles(), true);
}
Also used : CvsLightweightFile(com.intellij.cvsSupport2.actions.cvsContext.CvsLightweightFile) CheckoutProjectOperation(com.intellij.cvsSupport2.cvsoperations.cvsCheckOut.CheckoutProjectOperation) CvsEntriesManager(com.intellij.cvsSupport2.application.CvsEntriesManager) VirtualFile(com.intellij.openapi.vfs.VirtualFile) CvsLightweightFile(com.intellij.cvsSupport2.actions.cvsContext.CvsLightweightFile) File(java.io.File)

Example 14 with CvsHandler

use of com.intellij.cvsSupport2.cvshandlers.CvsHandler in project intellij-community by JetBrains.

the class CommandCvsHandler method createCommitHandler.

public static CvsHandler createCommitHandler(FilePath[] selectedFiles, String commitMessage, String title, boolean makeNewFilesReadOnly, Project project, final boolean tagFilesAfterCommit, final String tagName, @NotNull final List<File> dirsToPrune) {
    final CommitFilesOperation operation = new CommitFilesOperation(commitMessage, makeNewFilesReadOnly);
    if (selectedFiles != null) {
        for (FilePath selectedFile : selectedFiles) {
            operation.addFile(selectedFile.getIOFile());
        }
    }
    if (!dirsToPrune.isEmpty()) {
        operation.addFinishAction(() -> {
            final IOFilesBasedDirectoryPruner pruner = new IOFilesBasedDirectoryPruner(null);
            for (File dir : dirsToPrune) {
                pruner.addFile(dir);
            }
            pruner.execute();
        });
    }
    final CommandCvsHandler result = new CommandCvsHandler(title, operation, FileSetToBeUpdated.selectedFiles(selectedFiles));
    if (tagFilesAfterCommit) {
        result.addOperation(new TagOperation(selectedFiles, tagName, false, CvsConfiguration.getInstance(project).OVERRIDE_EXISTING_TAG_FOR_PROJECT));
    }
    return result;
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) CommitFilesOperation(com.intellij.cvsSupport2.cvsoperations.cvsCommit.CommitFilesOperation) TagOperation(com.intellij.cvsSupport2.cvsoperations.cvsTagOrBranch.TagOperation) VirtualFile(com.intellij.openapi.vfs.VirtualFile) CvsLightweightFile(com.intellij.cvsSupport2.actions.cvsContext.CvsLightweightFile) File(java.io.File)

Example 15 with CvsHandler

use of com.intellij.cvsSupport2.cvshandlers.CvsHandler in project intellij-community by JetBrains.

the class CommandCvsHandler method createUneditHandler.

public static CvsHandler createUneditHandler(VirtualFile[] selectedFiles, boolean makeNewFilesReadOnly) {
    final UneditOperation operation = new UneditOperation(makeNewFilesReadOnly);
    operation.addFiles(selectedFiles);
    return new CommandCvsHandler(CvsBundle.message("operation.name.unedit"), operation, FileSetToBeUpdated.selectedFiles(selectedFiles));
}
Also used : UneditOperation(com.intellij.cvsSupport2.cvsoperations.cvsEdit.UneditOperation)

Aggregations

VirtualFile (com.intellij.openapi.vfs.VirtualFile)11 CommandCvsHandler (com.intellij.cvsSupport2.cvshandlers.CommandCvsHandler)10 CvsHandler (com.intellij.cvsSupport2.cvshandlers.CvsHandler)10 CvsOperationExecutor (com.intellij.cvsSupport2.cvsExecution.CvsOperationExecutor)9 Project (com.intellij.openapi.project.Project)9 FilePath (com.intellij.openapi.vcs.FilePath)9 File (java.io.File)7 CvsLightweightFile (com.intellij.cvsSupport2.actions.cvsContext.CvsLightweightFile)4 CvsTabbedWindow (com.intellij.cvsSupport2.ui.CvsTabbedWindow)4 CvsContext (com.intellij.cvsSupport2.actions.cvsContext.CvsContext)3 CvsConfiguration (com.intellij.cvsSupport2.config.CvsConfiguration)3 SelectCvsConfigurationDialog (com.intellij.cvsSupport2.config.ui.SelectCvsConfigurationDialog)2 TagOperation (com.intellij.cvsSupport2.cvsoperations.cvsTagOrBranch.TagOperation)2 CreateTagDialog (com.intellij.cvsSupport2.cvsoperations.cvsTagOrBranch.ui.CreateTagDialog)2 UpdateOperation (com.intellij.cvsSupport2.cvsoperations.cvsUpdate.UpdateOperation)2 WatchOperation (com.intellij.cvsSupport2.cvsoperations.cvsWatch.WatchOperation)2 CheckoutWizard (com.intellij.cvsSupport2.ui.experts.checkout.CheckoutWizard)2 VcsException (com.intellij.openapi.vcs.VcsException)2 VcsContext (com.intellij.openapi.vcs.actions.VcsContext)2 ArrayList (java.util.ArrayList)2