use of com.intellij.cvsSupport2.cvsoperations.cvsAnnotate.AnnotateOperation 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.cvsoperations.cvsAnnotate.AnnotateOperation 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.cvsoperations.cvsAnnotate.AnnotateOperation in project intellij-community by JetBrains.
the class CvsAnnotationProvider method annotate.
public FileAnnotation annotate(VirtualFile virtualFile) throws VcsException {
final File file = new File(virtualFile.getPath());
final File cvsLightweightFile = CvsUtil.getCvsLightweightFileForFile(file);
final String revision = CvsUtil.getRevisionFor(file);
final CvsEntriesManager entriesManager = CvsEntriesManager.getInstance();
final CvsConnectionSettings root = entriesManager.getCvsConnectionSettingsFor(file.getParentFile());
final boolean binary = annotateBinary(virtualFile, root);
final AnnotateOperation operation = executeOperation(cvsLightweightFile, revision, root, binary, true);
final FilePath filePath = VcsContextFactory.SERVICE.getInstance().createFilePathOn(virtualFile);
final List<VcsFileRevision> revisions = myCvsHistoryProvider.createRevisions(filePath);
final Annotation[] lineAnnotations = operation.getLineAnnotations();
adjustAnnotation(revisions, lineAnnotations);
return new CvsFileAnnotation(operation.getContent(), lineAnnotations, revisions, virtualFile, revision, myProject);
}
Aggregations