Search in sources :

Example 6 with CvsEnvironment

use of com.intellij.cvsSupport2.connections.CvsEnvironment in project intellij-community by JetBrains.

the class GetModuleContentOperation method createGetModuleContentOperation.

private LocalPathIndifferentOperation createGetModuleContentOperation(RepositoryPathProvider adminWriter, CvsEnvironment environment, final String moduleName) {
    final LocalPathIndifferentOperation operation = new LocalPathIndifferentOperation(new AdminReaderOnStoredRepositoryPath(adminWriter), environment) {

        private boolean myIsInModule = false;

        @Override
        protected Command createCommand(CvsRootProvider root, CvsExecutionEnvironment cvsExecutionEnvironment) {
            final CheckoutCommand result = new CheckoutCommand(null);
            result.addModule(moduleName);
            result.setRecursive(true);
            return result;
        }

        @Override
        protected ILocalFileReader createLocalFileReader() {
            return ConstantLocalFileReader.FOR_EXISTING_FILE;
        }

        @Override
        protected String getOperationName() {
            return "checkout";
        }

        @Override
        protected ILocalFileWriter createLocalFileWriter(String cvsRoot, UpdatedFilesManager mergedFilesCollector, CvsExecutionEnvironment cvsExecutionEnvironment) {
            return DeafLocalFileWriter.INSTANCE;
        }

        @Override
        public void messageSent(String message, final byte[] byteMessage, boolean error, boolean tagged) {
            super.messageSent(message, byteMessage, error, tagged);
            myStreamingDirectoryContentListener.setModulePath(myAdminWriterStoringRepositoryPath.getModulePath());
            final Matcher matcher = UPDATING_PATTERN.matcher(message);
            if (matcher.matches()) {
                if (myModuleLocation != null && myModuleLocation.equals(matcher.group(1))) {
                    myIsInModule = true;
                } else {
                    myStreamingDirectoryContentListener.messageSent(message);
                    myIsInModule = false;
                }
            } else if (DirectoryContentListener.moduleMessage_ver1(message)) {
                myIsInModule = true;
            }
            if (myIsInModule) {
                myStreamingDirectoryContentListener.messageSent(message);
            }
            final DirectoryContent streamingDirectoryContent = myStreamingDirectoryContentListener.getDirectoryContent();
            if (myStreamingListener != null) {
                final long timePassed = System.currentTimeMillis() - timeStamp;
                if (streamingDirectoryContent.getTotalSize() > 0 && timePassed > 25L) {
                    myStreamingListener.consume(streamingDirectoryContent);
                    final DirectoryContentListener newListener = new DirectoryContentListener();
                    newListener.setModuleName(myStreamingDirectoryContentListener.getModuleName());
                    myStreamingDirectoryContentListener = newListener;
                    timeStamp = System.currentTimeMillis();
                }
            } else {
                myDirectoryContentListener.getDirectoryContent().copyDataFrom(streamingDirectoryContent);
            }
        }

        @Override
        public void modifyOptions(GlobalOptions options) {
            super.modifyOptions(options);
            options.setDoNoChanges(true);
        }
    };
    operation.addFinishAction(() -> myStreamingListener.consume(myStreamingDirectoryContentListener.getDirectoryContent()));
    return operation;
}
Also used : GlobalOptions(org.netbeans.lib.cvsclient.command.GlobalOptions) AdminReaderOnStoredRepositoryPath(com.intellij.cvsSupport2.cvsoperations.javacvsSpecificImpls.AdminReaderOnStoredRepositoryPath) CheckoutCommand(org.netbeans.lib.cvsclient.command.checkout.CheckoutCommand) Matcher(java.util.regex.Matcher) CvsRootProvider(com.intellij.cvsSupport2.connections.CvsRootProvider)

Example 7 with CvsEnvironment

use of com.intellij.cvsSupport2.connections.CvsEnvironment in project intellij-community by JetBrains.

the class SelectCvsElementStep method isLogged.

private boolean isLogged(final CvsRootConfiguration selectedConfiguration) {
    myErrors.set(null);
    final LoginPerformer performer = new LoginPerformer(myProject, Collections.<CvsEnvironment>singletonList(selectedConfiguration), e -> myErrors.set(Boolean.TRUE));
    try {
        final boolean logged = performer.loginAll(false);
        return logged && myErrors.isNull();
    } catch (CvsRootException e) {
        Messages.showErrorDialog(e.getMessage(), CvsBundle.message("error.title.invalid.cvs.root"));
        return false;
    }
}
Also used : LoginPerformer(com.intellij.cvsSupport2.cvsoperations.common.LoginPerformer) CvsRootException(com.intellij.cvsSupport2.connections.CvsRootException)

Example 8 with CvsEnvironment

use of com.intellij.cvsSupport2.connections.CvsEnvironment in project intellij-community by JetBrains.

the class CheckoutProjectOperation method create.

public static CheckoutProjectOperation create(CvsEnvironment env, String[] moduleName, File targetLocation, boolean useAlternativeCheckoutDir, boolean makeNewFilesReadOnly) {
    final CvsApplicationLevelConfiguration config = CvsApplicationLevelConfiguration.getInstance();
    final KeywordSubstitutionWrapper substitution = KeywordSubstitutionWrapper.getValue(config.CHECKOUT_KEYWORD_SUBSTITUTION);
    final File root;
    final String directory;
    if (useAlternativeCheckoutDir && targetLocation.getParentFile() == null) {
        root = targetLocation;
        directory = getModuleRootName(moduleName);
    } else if (useAlternativeCheckoutDir) {
        root = targetLocation.getParentFile();
        directory = targetLocation.getName();
    } else {
        root = targetLocation;
        directory = null;
    }
    return new CheckoutProjectOperation(moduleName, env, makeNewFilesReadOnly, root, directory, config.CHECKOUT_PRUNE_EMPTY_DIRECTORIES, substitution == null ? null : substitution.getSubstitution());
}
Also used : CvsApplicationLevelConfiguration(com.intellij.cvsSupport2.config.CvsApplicationLevelConfiguration) KeywordSubstitutionWrapper(com.intellij.cvsSupport2.keywordSubstitution.KeywordSubstitutionWrapper) File(java.io.File)

Example 9 with CvsEnvironment

use of com.intellij.cvsSupport2.connections.CvsEnvironment in project intellij-community by JetBrains.

the class CvsAnnotationProvider method executeOperation.

private AnnotateOperation executeOperation(File file, String revision, CvsEnvironment root, boolean binary, boolean retryOnFailure) throws VcsException {
    final AnnotateOperation operation = new AnnotateOperation(file, revision, root, binary);
    final CvsOperationExecutor executor = new CvsOperationExecutor(myProject);
    executor.performActionSync(new CommandCvsHandler(CvsBundle.getAnnotateOperationName(), operation), CvsOperationExecutorCallback.EMPTY);
    final CvsResult result = executor.getResult();
    if (result.hasErrors()) {
        if (!retryOnFailure) {
            throw result.composeError();
        }
        for (VcsException error : result.getErrors()) {
            for (String message : error.getMessages()) {
                if (message.contains(INVALID_OPTION_F) || message.contains(USAGE_CVSNTSRV_SERVER)) {
                    ourDoNotAnnotateBinaryRoots.add(root.getCvsRootAsString());
                    return executeOperation(file, revision, root, false, false);
                }
            }
        }
        throw result.composeError();
    }
    return operation;
}
Also used : CvsOperationExecutor(com.intellij.cvsSupport2.cvsExecution.CvsOperationExecutor) VcsException(com.intellij.openapi.vcs.VcsException) CommandCvsHandler(com.intellij.cvsSupport2.cvshandlers.CommandCvsHandler) AnnotateOperation(com.intellij.cvsSupport2.cvsoperations.cvsAnnotate.AnnotateOperation) CvsResult(com.intellij.openapi.cvsIntegration.CvsResult)

Example 10 with CvsEnvironment

use of com.intellij.cvsSupport2.connections.CvsEnvironment in project intellij-community by JetBrains.

the class CvsCommittedChangesProvider method loadCommittedChanges.

public void loadCommittedChanges(ChangeBrowserSettings settings, RepositoryLocation location, int maxCount, final AsynchConsumer<CommittedChangeList> consumer) throws VcsException {
    try {
        final CvsRepositoryLocation cvsLocation = (CvsRepositoryLocation) location;
        final String module = cvsLocation.getModuleName();
        final CvsEnvironment connectionSettings = cvsLocation.getEnvironment();
        if (connectionSettings.isOffline()) {
            return;
        }
        final CvsChangeListsBuilder builder = new CvsChangeListsBuilder(module, connectionSettings, myProject, cvsLocation.getRootFile());
        final Date dateTo = settings.getDateBeforeFilter();
        Date dateFrom = settings.getDateAfterFilter();
        if (dateFrom == null) {
            final Calendar calendar = Calendar.getInstance();
            calendar.set(1970, Calendar.MARCH, 2);
            dateFrom = calendar.getTime();
        }
        final ChangeBrowserSettings.Filter filter = settings.createFilter();
        final Set<CvsChangeList> controlSet = new HashSet<>();
        final LoadHistoryOperation operation = new LoadHistoryOperation(connectionSettings, module, dateFrom, dateTo, wrapper -> {
            final List<RevisionWrapper> wrappers = builder.revisionWrappersFromLog(wrapper);
            if (wrappers != null) {
                for (RevisionWrapper revisionWrapper : wrappers) {
                    final CvsChangeList changeList = builder.addRevision(revisionWrapper);
                    if (controlSet.contains(changeList))
                        continue;
                    controlSet.add(changeList);
                    if (filter.accepts(changeList)) {
                        consumer.consume(changeList);
                    }
                }
            }
        });
        final CvsResult executionResult = operation.run(myProject);
        if (executionResult.isCanceled()) {
            throw new ProcessCanceledException();
        } else if (executionResult.hasErrors()) {
            throw executionResult.composeError();
        }
    } finally {
        consumer.finished();
    }
}
Also used : CvsResult(com.intellij.openapi.cvsIntegration.CvsResult) ChangeBrowserSettings(com.intellij.openapi.vcs.versionBrowser.ChangeBrowserSettings) CvsEnvironment(com.intellij.cvsSupport2.connections.CvsEnvironment) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException)

Aggregations

CvsEnvironment (com.intellij.cvsSupport2.connections.CvsEnvironment)4 File (java.io.File)4 CvsResult (com.intellij.openapi.cvsIntegration.CvsResult)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 CvsRootProvider (com.intellij.cvsSupport2.connections.CvsRootProvider)2 CvsOperationExecutor (com.intellij.cvsSupport2.cvsExecution.CvsOperationExecutor)2 CommandCvsHandler (com.intellij.cvsSupport2.cvshandlers.CommandCvsHandler)2 AnnotateOperation (com.intellij.cvsSupport2.cvsoperations.cvsAnnotate.AnnotateOperation)2 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)2 FilePath (com.intellij.openapi.vcs.FilePath)2 List (java.util.List)2 Nullable (org.jetbrains.annotations.Nullable)2 CheckoutCommand (org.netbeans.lib.cvsclient.command.checkout.CheckoutCommand)2 Revision (org.netbeans.lib.cvsclient.command.log.Revision)2 CvsChangeList (com.intellij.cvsSupport2.changeBrowser.CvsChangeList)1 CvsApplicationLevelConfiguration (com.intellij.cvsSupport2.config.CvsApplicationLevelConfiguration)1 CvsConnectionSettings (com.intellij.cvsSupport2.connections.CvsConnectionSettings)1 CvsRootException (com.intellij.cvsSupport2.connections.CvsRootException)1 DefaultCvsOperationExecutorCallback (com.intellij.cvsSupport2.cvsExecution.DefaultCvsOperationExecutorCallback)1 LoginPerformer (com.intellij.cvsSupport2.cvsoperations.common.LoginPerformer)1