use of com.intellij.cvsSupport2.connections.CvsEnvironment in project intellij-community by JetBrains.
the class CvsHistoryProvider method createRevisions.
private List<VcsFileRevision> createRevisions(final CvsEnvironment connectionSettings, final File lightweightFileForFile) {
final LocalPathIndifferentLogOperation logOperation = new LocalPathIndifferentLogOperation(connectionSettings);
logOperation.addFile(lightweightFileForFile);
final CvsOperationExecutor executor = new CvsOperationExecutor(myProject);
final ArrayList<VcsFileRevision> result = new ArrayList<>();
executor.performActionSync(new CommandCvsHandler(CvsBundle.message("operation.name.load.file.content"), logOperation), new DefaultCvsOperationExecutorCallback() {
@Override
public void executionFinishedSuccessfully() {
final LogInformation firstLogInformation = logOperation.getFirstLogInformation();
if (firstLogInformation != null) {
final List<Revision> revisionList = firstLogInformation.getRevisionList();
for (Revision revision : revisionList) {
result.add(new CvsFileRevisionImpl(revision, lightweightFileForFile, firstLogInformation, connectionSettings, myProject));
}
}
}
});
Collections.sort(result, Collections.reverseOrder(VcsFileRevisionComparator.INSTANCE));
return result;
}
use of com.intellij.cvsSupport2.connections.CvsEnvironment 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.cvsSupport2.connections.CvsEnvironment in project intellij-community by JetBrains.
the class CvsAnnotationProvider method annotate.
public FileAnnotation annotate(VirtualFile cvsVirtualFile, String revision, CvsEnvironment environment) throws VcsException {
// the VirtualFile has a full path if annotate is called from history (when we have a real file on disk),
// and has the path equal to a CVS module name if annotate is called from the CVS repository browser
// (when there's no real path)
boolean hasLocalFile = false;
File cvsFile = new File(cvsVirtualFile.getPath());
if (cvsFile.isAbsolute()) {
hasLocalFile = true;
cvsFile = new File(CvsUtil.getModuleName(cvsVirtualFile));
}
final boolean binary = annotateBinary(cvsVirtualFile, environment);
final AnnotateOperation annotateOperation = executeOperation(cvsFile, revision, environment, binary, true);
final Annotation[] lineAnnotations = annotateOperation.getLineAnnotations();
final List<VcsFileRevision> revisions;
if (hasLocalFile) {
final FilePath filePath = VcsContextFactory.SERVICE.getInstance().createFilePathOn(cvsVirtualFile);
revisions = myCvsHistoryProvider.createRevisions(filePath);
// in annotation cvs returns only 8 symbols of username
// try to find usernames in history and use them
adjustAnnotation(revisions, lineAnnotations);
} else {
// imitation
revisions = new ArrayList<>();
final Set<String> usedRevisions = new HashSet<>();
for (Annotation annotation : lineAnnotations) {
if (!usedRevisions.contains(annotation.getRevision())) {
revisions.add(new RevisionPresentation(annotation.getRevision(), annotation.getUserName(), annotation.getDate()));
usedRevisions.add(annotation.getRevision());
}
}
}
return new CvsFileAnnotation(annotateOperation.getContent(), lineAnnotations, revisions, cvsVirtualFile, revision, myProject);
}
use of com.intellij.cvsSupport2.connections.CvsEnvironment in project intellij-community by JetBrains.
the class RTagOperation method createOn.
public static RTagOperation[] createOn(FilePath[] files, String tagName, boolean overrideExisting) {
Map<CvsEnvironment, List<File>> envToFiles = new HashMap<>();
for (FilePath file : files) {
CvsConnectionSettings cvsConnectionSettings = CvsUtil.getCvsConnectionSettings(file);
if (!envToFiles.containsKey(cvsConnectionSettings))
envToFiles.put(cvsConnectionSettings, new ArrayList<>());
envToFiles.get(cvsConnectionSettings).add(file.getIOFile());
}
ArrayList<RTagOperation> result = new ArrayList<>();
for (CvsEnvironment cvsEnvironment : envToFiles.keySet()) {
RTagOperation rTagOperation = new RTagOperation(cvsEnvironment, tagName, overrideExisting);
result.add(rTagOperation);
List<File> iofiles = envToFiles.get(cvsEnvironment);
for (File file : iofiles) {
rTagOperation.addFile(file);
}
}
return result.toArray(new RTagOperation[result.size()]);
}
use of com.intellij.cvsSupport2.connections.CvsEnvironment in project intellij-community by JetBrains.
the class GetModuleContentOperation method createExpandingRepositoryPathOperation.
private LocalPathIndifferentOperation createExpandingRepositoryPathOperation(AdminWriterStoringRepositoryPath adminWriter, CvsEnvironment environment, final String moduleName) {
return new LocalPathIndifferentOperation(adminWriter, environment) {
@Override
protected Command createCommand(CvsRootProvider root, CvsExecutionEnvironment cvsExecutionEnvironment) {
final CheckoutCommand result = new CheckoutCommand(null);
result.addModule(moduleName);
result.setRecursive(false);
return result;
}
@Override
protected ILocalFileWriter createLocalFileWriter(String cvsRoot, UpdatedFilesManager mergedFilesCollector, CvsExecutionEnvironment cvsExecutionEnvironment) {
return DeafLocalFileWriter.INSTANCE;
}
@Override
protected String getOperationName() {
return "checkout";
}
@Override
public void moduleExpanded(String module) {
super.moduleExpanded(module);
if (myModuleLocation == null) {
myModuleLocation = module;
myStreamingDirectoryContentListener.setModuleName(myModuleLocation);
}
}
};
}
Aggregations