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