Search in sources :

Example 1 with CvsResult

use of com.intellij.openapi.cvsIntegration.CvsResult in project intellij-community by JetBrains.

the class CvsStatusEnvironment method updateDirectories.

@NotNull
public UpdateSession updateDirectories(@NotNull FilePath[] contentRoots, final UpdatedFiles updatedFiles, ProgressIndicator progressIndicator, @NotNull final Ref<SequentialUpdatesContext> context) {
    final UpdateSettings updateSettings = UpdateSettings.DONT_MAKE_ANY_CHANGES;
    final UpdateHandler handler = CommandCvsHandler.createUpdateHandler(contentRoots, updateSettings, myProject, updatedFiles);
    handler.addCvsListener(new UpdatedFilesProcessor(updatedFiles));
    CvsOperationExecutor cvsOperationExecutor = new CvsOperationExecutor(true, myProject, ModalityState.defaultModalityState());
    cvsOperationExecutor.setShowErrors(false);
    cvsOperationExecutor.performActionSync(handler, CvsOperationExecutorCallback.EMPTY);
    final CvsResult result = cvsOperationExecutor.getResult();
    return new UpdateSessionAdapter(result.getErrorsAndWarnings(), result.isCanceled());
}
Also used : UpdateHandler(com.intellij.cvsSupport2.cvshandlers.UpdateHandler) UpdatedFilesProcessor(com.intellij.cvsSupport2.updateinfo.UpdatedFilesProcessor) CvsOperationExecutor(com.intellij.cvsSupport2.cvsExecution.CvsOperationExecutor) UpdateSettings(com.intellij.cvsSupport2.actions.update.UpdateSettings) CvsResult(com.intellij.openapi.cvsIntegration.CvsResult) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with CvsResult

use of com.intellij.openapi.cvsIntegration.CvsResult in project intellij-community by JetBrains.

the class CvsCommittedChangesProvider method getOneList.

@Nullable
@Override
public Pair<CvsChangeList, FilePath> getOneList(VirtualFile file, final VcsRevisionNumber number) throws VcsException {
    final File ioFile = new File(file.getPath());
    final FilePath filePath = VcsContextFactory.SERVICE.getInstance().createFilePathOn(ioFile);
    final VirtualFile vcsRoot = ProjectLevelVcsManager.getInstance(myProject).getVcsRootFor(filePath);
    final CvsRepositoryLocation cvsLocation = getLocationFor(filePath);
    if (cvsLocation == null)
        return null;
    final String module = CvsUtil.getModuleName(vcsRoot);
    final CvsEnvironment connectionSettings = cvsLocation.getEnvironment();
    if (connectionSettings.isOffline()) {
        return null;
    }
    final CvsChangeListsBuilder builder = new CvsChangeListsBuilder(module, connectionSettings, myProject, vcsRoot);
    final Ref<CvsChangeList> result = new Ref<>();
    final LoadHistoryOperation operation = new LoadHistoryOperation(connectionSettings, wrapper -> {
        final List<Revision> revisions = wrapper.getRevisions();
        if (revisions.isEmpty())
            return;
        final RevisionWrapper revision = new RevisionWrapper(wrapper.getFile(), revisions.get(0), null);
        result.set(builder.addRevision(revision));
    }, cvsLocation.getModuleName(), number.asString());
    final CvsResult executionResult = operation.run(myProject);
    if (executionResult.isCanceled()) {
        throw new ProcessCanceledException();
    } else if (executionResult.hasErrors()) {
        throw executionResult.composeError();
    }
    if (result.isNull()) {
        return null;
    }
    final Date commitDate = result.get().getCommitDate();
    final CvsEnvironment rootConnectionSettings = CvsEntriesManager.getInstance().getCvsConnectionSettingsFor(vcsRoot);
    final long t = commitDate.getTime();
    final Date dateFrom = new Date(t - CvsChangeList.SUITABLE_DIFF);
    final Date dateTo = new Date(t + CvsChangeList.SUITABLE_DIFF);
    final LoadHistoryOperation operation2 = new LoadHistoryOperation(rootConnectionSettings, module, dateFrom, dateTo, wrapper -> {
        final List<RevisionWrapper> wrappers = builder.revisionWrappersFromLog(wrapper);
        if (wrappers != null) {
            for (RevisionWrapper revisionWrapper : wrappers) {
                if (result.get().containsFileRevision(revisionWrapper)) {
                    continue;
                }
                builder.addRevision(revisionWrapper);
            }
        }
    });
    final CvsResult cvsResult = operation2.run(myProject);
    if (cvsResult.hasErrors()) {
        throw cvsResult.composeError();
    }
    return Pair.create(result.get(), filePath);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) CvsResult(com.intellij.openapi.cvsIntegration.CvsResult) Ref(com.intellij.openapi.util.Ref) Revision(org.netbeans.lib.cvsclient.command.log.Revision) CvsEnvironment(com.intellij.cvsSupport2.connections.CvsEnvironment) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with CvsResult

use of com.intellij.openapi.cvsIntegration.CvsResult in project intellij-community by JetBrains.

the class CvsContentRevision method getContentAsBytes.

@Nullable
@Override
public byte[] getContentAsBytes() throws VcsException {
    if (myContent == null) {
        final GetFileContentOperation operation = new GetFileContentOperation(myFile, myEnvironment, myRevision);
        CvsOperationExecutor executor = new CvsOperationExecutor(myProject);
        executor.performActionSync(new CommandCvsHandler(CvsBundle.message("operation.name.load.file"), operation), CvsOperationExecutorCallback.EMPTY);
        CvsResult result = executor.getResult();
        if (result.isCanceled()) {
            throw new ProcessCanceledException();
        }
        if (result.hasErrors()) {
            throw result.composeError();
        }
        if (!operation.isLoaded()) {
            throw new VcsException("Network problem");
        }
        myContent = operation.getFileBytes();
    }
    return myContent;
}
Also used : GetFileContentOperation(com.intellij.cvsSupport2.cvsoperations.cvsContent.GetFileContentOperation) CvsOperationExecutor(com.intellij.cvsSupport2.cvsExecution.CvsOperationExecutor) VcsException(com.intellij.openapi.vcs.VcsException) CommandCvsHandler(com.intellij.cvsSupport2.cvshandlers.CommandCvsHandler) CvsResult(com.intellij.openapi.cvsIntegration.CvsResult) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with CvsResult

use of com.intellij.openapi.cvsIntegration.CvsResult in project intellij-community by JetBrains.

the class CvsRootConfiguration method testConnection.

public void testConnection(Project project) throws AuthenticationException, IOException {
    final IConnection connection = createSettings().createConnection(new ReadWriteStatistics());
    final ErrorMessagesProcessor errorProcessor = new ErrorMessagesProcessor();
    final CvsExecutionEnvironment cvsExecutionEnvironment = new CvsExecutionEnvironment(errorProcessor, CvsExecutionEnvironment.DUMMY_STOPPER, errorProcessor, PostCvsActivity.DEAF, project);
    final CvsResult result = new CvsResultEx();
    try {
        ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
            final GetModulesListOperation operation = new GetModulesListOperation(createSettings());
            final CvsRootProvider cvsRootProvider = operation.getCvsRootProvider();
            try {
                if (connection instanceof SelfTestingConnection) {
                    ((SelfTestingConnection) connection).test(CvsListenerWithProgress.createOnProgress());
                }
                operation.execute(cvsRootProvider, cvsExecutionEnvironment, connection, DummyProgressViewer.INSTANCE);
            } catch (ValidRequestsExpectedException ex) {
                result.addError(new CvsException(ex, cvsRootProvider.getCvsRootAsString()));
            } catch (CommandException ex) {
                result.addError(new CvsException(ex.getUnderlyingException(), cvsRootProvider.getCvsRootAsString()));
            } catch (ProcessCanceledException ex) {
                result.setIsCanceled();
            } catch (BugLog.BugException e) {
                LOG.error(e);
            } catch (Exception e) {
                result.addError(new CvsException(e, cvsRootProvider.getCvsRootAsString()));
            }
        }, CvsBundle.message("operation.name.test.connection"), true, null);
        if (result.isCanceled())
            throw new ProcessCanceledException();
        if (result.hasErrors()) {
            final VcsException vcsException = result.composeError();
            throw new AuthenticationException(vcsException.getLocalizedMessage(), vcsException.getCause());
        }
        final List<VcsException> errors = errorProcessor.getErrors();
        if (!errors.isEmpty()) {
            final VcsException firstError = errors.get(0);
            throw new AuthenticationException(firstError.getLocalizedMessage(), firstError);
        }
    } finally {
        connection.close();
    }
}
Also used : AuthenticationException(org.netbeans.lib.cvsclient.connection.AuthenticationException) CvsException(com.intellij.cvsSupport2.errorHandling.CvsException) IConnection(org.netbeans.lib.cvsclient.connection.IConnection) CommandException(org.netbeans.lib.cvsclient.command.CommandException) ValidRequestsExpectedException(org.netbeans.lib.cvsclient.ValidRequestsExpectedException) ErrorMessagesProcessor(com.intellij.cvsSupport2.cvsoperations.cvsErrors.ErrorMessagesProcessor) CvsResult(com.intellij.openapi.cvsIntegration.CvsResult) ValidRequestsExpectedException(org.netbeans.lib.cvsclient.ValidRequestsExpectedException) CvsException(com.intellij.cvsSupport2.errorHandling.CvsException) AuthenticationException(org.netbeans.lib.cvsclient.connection.AuthenticationException) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException) VcsException(com.intellij.openapi.vcs.VcsException) CommandException(org.netbeans.lib.cvsclient.command.CommandException) IOException(java.io.IOException) BugLog(org.netbeans.lib.cvsclient.util.BugLog) CvsExecutionEnvironment(com.intellij.cvsSupport2.cvsoperations.common.CvsExecutionEnvironment) GetModulesListOperation(com.intellij.cvsSupport2.cvsoperations.cvsContent.GetModulesListOperation) VcsException(com.intellij.openapi.vcs.VcsException) CvsResultEx(com.intellij.cvsSupport2.CvsResultEx) ReadWriteStatistics(com.intellij.cvsSupport2.javacvsImpl.io.ReadWriteStatistics) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException)

Example 5 with CvsResult

use of com.intellij.openapi.cvsIntegration.CvsResult in project intellij-community by JetBrains.

the class CvsVcs2 method executeOperation.

public static void executeOperation(String title, CvsOperation operation, final Project project) throws VcsException {
    CvsOperationExecutor executor = new CvsOperationExecutor(project);
    executor.performActionSync(new CommandCvsHandler(title, operation), CvsOperationExecutorCallback.EMPTY);
    CvsResult result = executor.getResult();
    if (result.hasErrors()) {
        throw result.composeError();
    }
}
Also used : CvsOperationExecutor(com.intellij.cvsSupport2.cvsExecution.CvsOperationExecutor) CommandCvsHandler(com.intellij.cvsSupport2.cvshandlers.CommandCvsHandler) CvsResult(com.intellij.openapi.cvsIntegration.CvsResult)

Aggregations

CvsResult (com.intellij.openapi.cvsIntegration.CvsResult)11 CvsOperationExecutor (com.intellij.cvsSupport2.cvsExecution.CvsOperationExecutor)7 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)6 CommandCvsHandler (com.intellij.cvsSupport2.cvshandlers.CommandCvsHandler)5 VcsException (com.intellij.openapi.vcs.VcsException)3 CvsEnvironment (com.intellij.cvsSupport2.connections.CvsEnvironment)2 UpdateHandler (com.intellij.cvsSupport2.cvshandlers.UpdateHandler)2 UpdatedFilesProcessor (com.intellij.cvsSupport2.updateinfo.UpdatedFilesProcessor)2 NotNull (org.jetbrains.annotations.NotNull)2 Nullable (org.jetbrains.annotations.Nullable)2 CvsResultEx (com.intellij.cvsSupport2.CvsResultEx)1 UpdateSettings (com.intellij.cvsSupport2.actions.update.UpdateSettings)1 UpdateSettingsOnCvsConfiguration (com.intellij.cvsSupport2.actions.update.UpdateSettingsOnCvsConfiguration)1 CvsConfiguration (com.intellij.cvsSupport2.config.CvsConfiguration)1 ModalityContextImpl (com.intellij.cvsSupport2.cvsExecution.ModalityContextImpl)1 CvsExecutionEnvironment (com.intellij.cvsSupport2.cvsoperations.common.CvsExecutionEnvironment)1 AnnotateOperation (com.intellij.cvsSupport2.cvsoperations.cvsAnnotate.AnnotateOperation)1 GetFileContentOperation (com.intellij.cvsSupport2.cvsoperations.cvsContent.GetFileContentOperation)1 GetModulesListOperation (com.intellij.cvsSupport2.cvsoperations.cvsContent.GetModulesListOperation)1 ErrorMessagesProcessor (com.intellij.cvsSupport2.cvsoperations.cvsErrors.ErrorMessagesProcessor)1