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());
}
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);
}
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;
}
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();
}
}
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();
}
}
Aggregations