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