Search in sources :

Example 1 with Annotation

use of com.intellij.cvsSupport2.cvsoperations.cvsAnnotate.Annotation 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);
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) AnnotateOperation(com.intellij.cvsSupport2.cvsoperations.cvsAnnotate.AnnotateOperation) FileAnnotation(com.intellij.openapi.vcs.annotate.FileAnnotation) Annotation(com.intellij.cvsSupport2.cvsoperations.cvsAnnotate.Annotation) VcsFileRevision(com.intellij.openapi.vcs.history.VcsFileRevision) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 2 with Annotation

use of com.intellij.cvsSupport2.cvsoperations.cvsAnnotate.Annotation in project intellij-community by JetBrains.

the class CvsFileAnnotation method getToolTip.

public String getToolTip(final int lineNumber) {
    if (lineNumber < 0 || lineNumber >= myAnnotations.length) {
        return "";
    }
    final Annotation annotation = myAnnotations[lineNumber];
    final String revision = annotation.getRevision();
    final Date date = annotation.getDate();
    final String author = annotation.getUserName();
    final String comment = myRevisionComments.get(revision);
    if (comment == null) {
        return "";
    }
    return CvsBundle.message("annotation.tooltip", revision, date, author, comment);
}
Also used : FileAnnotation(com.intellij.openapi.vcs.annotate.FileAnnotation) Annotation(com.intellij.cvsSupport2.cvsoperations.cvsAnnotate.Annotation)

Example 3 with Annotation

use of com.intellij.cvsSupport2.cvsoperations.cvsAnnotate.Annotation in project intellij-community by JetBrains.

the class CvsAnnotationProvider method adjustAnnotation.

private static void adjustAnnotation(@Nullable List<VcsFileRevision> revisions, @NotNull Annotation[] lineAnnotations) {
    if (revisions != null) {
        final Map<String, VcsFileRevision> revisionMap = new HashMap<>();
        for (VcsFileRevision vcsFileRevision : revisions) {
            revisionMap.put(vcsFileRevision.getRevisionNumber().asString(), vcsFileRevision);
        }
        for (Annotation lineAnnotation : lineAnnotations) {
            final String revisionNumber = lineAnnotation.getRevision();
            final VcsFileRevision revision = revisionMap.get(revisionNumber);
            if (revision != null) {
                lineAnnotation.setUser(revision.getAuthor());
                lineAnnotation.setDate(revision.getRevisionDate());
            }
        }
    }
}
Also used : VcsFileRevision(com.intellij.openapi.vcs.history.VcsFileRevision) FileAnnotation(com.intellij.openapi.vcs.annotate.FileAnnotation) Annotation(com.intellij.cvsSupport2.cvsoperations.cvsAnnotate.Annotation)

Example 4 with Annotation

use of com.intellij.cvsSupport2.cvsoperations.cvsAnnotate.Annotation 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);
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) CvsEntriesManager(com.intellij.cvsSupport2.application.CvsEntriesManager) CvsConnectionSettings(com.intellij.cvsSupport2.connections.CvsConnectionSettings) VcsFileRevision(com.intellij.openapi.vcs.history.VcsFileRevision) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) AnnotateOperation(com.intellij.cvsSupport2.cvsoperations.cvsAnnotate.AnnotateOperation) FileAnnotation(com.intellij.openapi.vcs.annotate.FileAnnotation) Annotation(com.intellij.cvsSupport2.cvsoperations.cvsAnnotate.Annotation)

Aggregations

Annotation (com.intellij.cvsSupport2.cvsoperations.cvsAnnotate.Annotation)4 FileAnnotation (com.intellij.openapi.vcs.annotate.FileAnnotation)4 VcsFileRevision (com.intellij.openapi.vcs.history.VcsFileRevision)3 AnnotateOperation (com.intellij.cvsSupport2.cvsoperations.cvsAnnotate.AnnotateOperation)2 FilePath (com.intellij.openapi.vcs.FilePath)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 File (java.io.File)2 CvsEntriesManager (com.intellij.cvsSupport2.application.CvsEntriesManager)1 CvsConnectionSettings (com.intellij.cvsSupport2.connections.CvsConnectionSettings)1