Search in sources :

Example 1 with CvsEntriesManager

use of com.intellij.cvsSupport2.application.CvsEntriesManager in project intellij-community by JetBrains.

the class CvsCommandOperation method execute.

public void execute(final CvsRootProvider root, final CvsExecutionEnvironment executionEnvironment, IConnection connection, IProgressViewer progressViewer) throws CommandException {
    final Command command = createCommand(root, executionEnvironment);
    if (command == null)
        return;
    LOG.assertTrue(connection != null, root.getCvsRootAsString());
    final CvsMessagesListener cvsMessagesListener = executionEnvironment.getCvsMessagesListener();
    final long start = System.currentTimeMillis();
    try {
        final IClientEnvironment clientEnvironment = createEnvironment(connection, root, myUpdatedFilesManager, executionEnvironment);
        myUpdatedFilesManager.setCvsFileSystem(clientEnvironment.getCvsFileSystem());
        final EventManager eventManager = new EventManager(CvsApplicationLevelConfiguration.getCharset());
        final IGlobalOptions globalOptions = command.getGlobalOptions();
        final IRequestProcessor requestProcessor = new RequestProcessor(clientEnvironment, globalOptions, eventManager, new StreamLogger(), executionEnvironment.getCvsCommandStopper(), PServerCvsSettings.getTimeoutMillis());
        eventManager.addFileInfoListener(this);
        eventManager.addEntryListener(this);
        eventManager.addMessageListener(this);
        eventManager.addModuleExpansionListener(this);
        final CvsMessagesTranslator cvsMessagesTranslator = new CvsMessagesTranslator(cvsMessagesListener, clientEnvironment.getCvsFileSystem(), myUpdatedFilesManager, root.getCvsRootAsString());
        cvsMessagesTranslator.registerTo(eventManager);
        final CvsEntriesManager cvsEntriesManager = CvsEntriesManager.getInstance();
        if (shouldMakeChangesOnTheLocalFileSystem()) {
            eventManager.addEntryListener(new MergeSupportingEntryListener(clientEnvironment, cvsEntriesManager, myUpdatedFilesManager));
            eventManager.addMessageListener(myUpdatedFilesManager);
        }
        modifyOptions(command.getGlobalOptions());
        final String commandString = composeCommandString(root, command);
        cvsMessagesListener.commandStarted(commandString);
        setProgressText(CvsBundle.message("progress.text.command.running.for.file", getOperationName(), root.getCvsRootAsString()));
        try {
            command.execute(requestProcessor, eventManager, eventManager, clientEnvironment, progressViewer);
        } catch (AuthenticationException e) {
            throw root.processException(new CommandException(e, "Authentication problem"));
        }
        cvsMessagesTranslator.operationCompleted();
    } catch (CommandException t) {
        throw root.processException(t);
    } finally {
        cvsMessagesListener.commandFinished(composeCommandString(root, command), System.currentTimeMillis() - start);
        executeFinishActions();
    }
}
Also used : IRequestProcessor(org.netbeans.lib.cvsclient.IRequestProcessor) AuthenticationException(org.netbeans.lib.cvsclient.connection.AuthenticationException) IgnoreFileFilterBasedOnCvsEntriesManager(com.intellij.cvsSupport2.cvsIgnore.IgnoreFileFilterBasedOnCvsEntriesManager) CvsEntriesManager(com.intellij.cvsSupport2.application.CvsEntriesManager) CvsMessagesTranslator(com.intellij.cvsSupport2.cvsoperations.cvsMessages.CvsMessagesTranslator) IClientEnvironment(org.netbeans.lib.cvsclient.IClientEnvironment) CvsMessagesListener(com.intellij.cvsSupport2.cvsoperations.cvsMessages.CvsMessagesListener) RequestProcessor(org.netbeans.lib.cvsclient.RequestProcessor) IRequestProcessor(org.netbeans.lib.cvsclient.IRequestProcessor)

Example 2 with CvsEntriesManager

use of com.intellij.cvsSupport2.application.CvsEntriesManager 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 3 with CvsEntriesManager

use of com.intellij.cvsSupport2.application.CvsEntriesManager in project intellij-community by JetBrains.

the class CvsUtil method restoreFile.

public static void restoreFile(final VirtualFile file) {
    CvsEntriesManager cvsEntriesManager = CvsEntriesManager.getInstance();
    VirtualFile directory = file == null ? null : file.getParent();
    LOG.assertTrue(directory != null);
    CvsInfo cvsInfo = cvsEntriesManager.getCvsInfoFor(directory);
    Entry entry = cvsInfo.getEntryNamed(file.getName());
    LOG.assertTrue(entry != null);
    String revision = entry.getRevision();
    LOG.assertTrue(StringUtil.startsWithChar(revision, '-'));
    String originalRevision = revision.substring(1);
    String date = Entry.formatLastModifiedDate(CvsStatusProvider.createDateDiffersTo(file.getTimeStamp()));
    String kwdSubstitution = entry.getOptions() == null ? "" : entry.getOptions();
    String stickyDataString = entry.getStickyData();
    Entry newEntry = Entry.createEntryForLine("/" + file.getName() + "/" + originalRevision + "/" + date + "/" + kwdSubstitution + "/" + stickyDataString);
    try {
        saveEntryForFile(CvsVfsUtil.getFileFor(file), newEntry);
        cvsEntriesManager.clearCachedEntriesFor(directory);
    } catch (final IOException e) {
        SwingUtilities.invokeLater(() -> Messages.showErrorDialog(CvsBundle.message("message.error.restore.entry", file.getPresentableUrl(), e.getLocalizedMessage()), CvsBundle.message("message.error.restore.entry.title")));
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Entry(org.netbeans.lib.cvsclient.admin.Entry) CvsEntriesManager(com.intellij.cvsSupport2.application.CvsEntriesManager) CvsInfo(com.intellij.cvsSupport2.application.CvsInfo) IOException(java.io.IOException)

Example 4 with CvsEntriesManager

use of com.intellij.cvsSupport2.application.CvsEntriesManager in project intellij-community by JetBrains.

the class CvsAnnotationProvider method annotate.

public FileAnnotation annotate(VirtualFile virtualFile) throws VcsException {
    final File file = new File(virtualFile.getPath());
    final File cvsLightweightFile = CvsUtil.getCvsLightweightFileForFile(file);
    final String revision = CvsUtil.getRevisionFor(file);
    final CvsEntriesManager entriesManager = CvsEntriesManager.getInstance();
    final CvsConnectionSettings root = entriesManager.getCvsConnectionSettingsFor(file.getParentFile());
    final boolean binary = annotateBinary(virtualFile, root);
    final AnnotateOperation operation = executeOperation(cvsLightweightFile, revision, root, binary, true);
    final FilePath filePath = VcsContextFactory.SERVICE.getInstance().createFilePathOn(virtualFile);
    final List<VcsFileRevision> revisions = myCvsHistoryProvider.createRevisions(filePath);
    final Annotation[] lineAnnotations = operation.getLineAnnotations();
    adjustAnnotation(revisions, lineAnnotations);
    return new CvsFileAnnotation(operation.getContent(), lineAnnotations, revisions, virtualFile, revision, myProject);
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) CvsEntriesManager(com.intellij.cvsSupport2.application.CvsEntriesManager) CvsConnectionSettings(com.intellij.cvsSupport2.connections.CvsConnectionSettings) VcsFileRevision(com.intellij.openapi.vcs.history.VcsFileRevision) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) AnnotateOperation(com.intellij.cvsSupport2.cvsoperations.cvsAnnotate.AnnotateOperation) FileAnnotation(com.intellij.openapi.vcs.annotate.FileAnnotation) Annotation(com.intellij.cvsSupport2.cvsoperations.cvsAnnotate.Annotation)

Example 5 with CvsEntriesManager

use of com.intellij.cvsSupport2.application.CvsEntriesManager in project intellij-community by JetBrains.

the class ToggleOfflineAction method setSelected.

public void setSelected(AnActionEvent e, boolean state) {
    CvsContext cvsContext = CvsContextWrapper.createInstance(e);
    final CvsEntriesManager entriesManager = CvsEntriesManager.getInstance();
    final VirtualFile file = cvsContext.getSelectedFile();
    if (file == null)
        return;
    final VirtualFile firstDirInChain = file.isDirectory() ? file : file.getParent();
    if (firstDirInChain == null)
        return;
    CvsConnectionSettings settings = entriesManager.getCvsConnectionSettingsFor(firstDirInChain);
    if (!settings.isValid()) {
        entriesManager.clearCachedEntriesFor(firstDirInChain);
        settings = entriesManager.getCvsConnectionSettingsFor(firstDirInChain);
    }
    if ((settings != null) && settings.isValid() && (state != settings.isOffline())) {
        VcsBalloonProblemNotifier.showOverChangesView(cvsContext.getProject(), state ? CvsBundle.message("set.offline.notification.text") : CvsBundle.message("set.online.notification.text"), state ? MessageType.WARNING : MessageType.INFO);
        settings.setOffline(state);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) CvsContext(com.intellij.cvsSupport2.actions.cvsContext.CvsContext) CvsEntriesManager(com.intellij.cvsSupport2.application.CvsEntriesManager) CvsConnectionSettings(com.intellij.cvsSupport2.connections.CvsConnectionSettings)

Aggregations

CvsEntriesManager (com.intellij.cvsSupport2.application.CvsEntriesManager)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 CvsConnectionSettings (com.intellij.cvsSupport2.connections.CvsConnectionSettings)2 File (java.io.File)2 Entry (org.netbeans.lib.cvsclient.admin.Entry)2 CvsContext (com.intellij.cvsSupport2.actions.cvsContext.CvsContext)1 CvsLightweightFile (com.intellij.cvsSupport2.actions.cvsContext.CvsLightweightFile)1 CvsInfo (com.intellij.cvsSupport2.application.CvsInfo)1 IgnoreFileFilterBasedOnCvsEntriesManager (com.intellij.cvsSupport2.cvsIgnore.IgnoreFileFilterBasedOnCvsEntriesManager)1 AnnotateOperation (com.intellij.cvsSupport2.cvsoperations.cvsAnnotate.AnnotateOperation)1 Annotation (com.intellij.cvsSupport2.cvsoperations.cvsAnnotate.Annotation)1 CheckoutProjectOperation (com.intellij.cvsSupport2.cvsoperations.cvsCheckOut.CheckoutProjectOperation)1 CvsMessagesListener (com.intellij.cvsSupport2.cvsoperations.cvsMessages.CvsMessagesListener)1 CvsMessagesTranslator (com.intellij.cvsSupport2.cvsoperations.cvsMessages.CvsMessagesTranslator)1 FilePath (com.intellij.openapi.vcs.FilePath)1 FileAnnotation (com.intellij.openapi.vcs.annotate.FileAnnotation)1 VcsFileRevision (com.intellij.openapi.vcs.history.VcsFileRevision)1 IOException (java.io.IOException)1 IClientEnvironment (org.netbeans.lib.cvsclient.IClientEnvironment)1 IRequestProcessor (org.netbeans.lib.cvsclient.IRequestProcessor)1