use of com.intellij.cvsSupport2.cvsoperations.common.CvsExecutionEnvironment 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();
}
}
use of com.intellij.cvsSupport2.cvsoperations.common.CvsExecutionEnvironment in project intellij-community by JetBrains.
the class StickyHeadGetter method getBranchHeadRevision.
@Nullable
protected String getBranchHeadRevision(final VirtualFile parent, final String name, final Convertor<CvsRevisionNumber, Boolean> chooser) {
final LocalPathIndifferentLogOperation operation = new LocalPathIndifferentLogOperation(new File(parent.getPath(), name));
final Ref<Boolean> logSuccess = new Ref<>(Boolean.TRUE);
final CvsExecutionEnvironment cvsExecutionEnvironment = new CvsExecutionEnvironment(new CvsMessagesAdapter(), CvsExecutionEnvironment.DUMMY_STOPPER, new ErrorProcessor() {
public void addError(VcsException ex) {
logSuccess.set(Boolean.FALSE);
}
public List<VcsException> getErrors() {
return null;
}
}, PostCvsActivity.DEAF, myProject);
try {
// should already be logged in
//operation.login(context);
operation.execute(cvsExecutionEnvironment, false);
} catch (VcsException | CommandAbortedException e) {
//
}
if (Boolean.TRUE.equals(logSuccess.get())) {
return extractRevision(operation, chooser);
}
return null;
}
use of com.intellij.cvsSupport2.cvsoperations.common.CvsExecutionEnvironment in project intellij-community by JetBrains.
the class GetAllBranchesOperation method createCommand.
protected Command createCommand(CvsRootProvider root, CvsExecutionEnvironment cvsExecutionEnvironment) {
final RlogCommand command = new RlogCommand();
command.setModuleName(myModuleName);
// TODO[yole]: it would be best to implement smarter handling similar to LoadHistoryOperation, but it's too cumbersome without a major refactoring
// see IDEADEV-14276
command.setSuppressEmptyHeaders(false);
return command;
}
use of com.intellij.cvsSupport2.cvsoperations.common.CvsExecutionEnvironment 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();
}
}
use of com.intellij.cvsSupport2.cvsoperations.common.CvsExecutionEnvironment in project intellij-community by JetBrains.
the class CvsCommandOperation method doExecute.
private void doExecute(final CvsExecutionEnvironment executionEnvironment, boolean underReadAction) throws VcsException {
final VcsException[] exc = new VcsException[1];
final Runnable action = () -> {
try {
final ReadWriteStatistics statistics = executionEnvironment.getReadWriteStatistics();
final Collection<CvsRootProvider> allCvsRoots;
try {
allCvsRoots = getAllCvsRoots();
} catch (CannotFindCvsRootException e) {
throw createVcsExceptionOn(e, null);
}
final IProgressViewer progressViewer = new IProgressViewer() {
@Override
public void setProgress(double value) {
final ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
if (progressIndicator != null)
progressIndicator.setFraction(value);
}
};
int count = 0;
final double step = 1.0 / allCvsRoots.size();
for (CvsRootProvider cvsRootProvider : allCvsRoots) {
try {
final double lowerBound = step * count;
final RangeProgressViewer partialProgress = new RangeProgressViewer(progressViewer, lowerBound, lowerBound + step);
myLastProcessedCvsRoot = cvsRootProvider.getCvsRootAsString();
execute(cvsRootProvider, executionEnvironment, statistics, partialProgress);
count++;
} catch (IOCommandException e) {
LOG.info(e);
throw createVcsExceptionOn(e.getIOException(), cvsRootProvider.getCvsRootAsString());
} catch (CommandException e) {
LOG.info(e);
final Exception underlyingException = e.getUnderlyingException();
if (underlyingException != null) {
LOG.info(underlyingException);
}
throw createVcsExceptionOn(underlyingException == null ? e : underlyingException, cvsRootProvider.getCvsRootAsString());
}
}
} catch (VcsException e) {
exc[0] = e;
}
};
if (underReadAction) {
ApplicationManager.getApplication().runReadAction(action);
} else {
action.run();
}
if (exc[0] != null)
throw exc[0];
}
Aggregations