Search in sources :

Example 1 with SvnFileRevision

use of org.jetbrains.idea.svn.history.SvnFileRevision in project intellij-community by JetBrains.

the class BaseSvnFileAnnotation method getToolTip.

public String getToolTip(final int lineNumber) {
    final CommitInfo info = myInfos.getOrNull(lineNumber);
    if (info == null)
        return "";
    SvnFileRevision revision = myRevisionMap.get(info.getRevision());
    if (revision != null) {
        String prefix = myInfos.getAnnotationSource(lineNumber).showMerged() ? "Merge source revision" : "Revision";
        return prefix + " " + info.getRevision() + ": " + revision.getCommitMessage();
    }
    return "";
}
Also used : SvnFileRevision(org.jetbrains.idea.svn.history.SvnFileRevision) CommitInfo(org.jetbrains.idea.svn.checkin.CommitInfo)

Example 2 with SvnFileRevision

use of org.jetbrains.idea.svn.history.SvnFileRevision in project intellij-community by JetBrains.

the class SvnAnnotationProvider method restore.

@Nullable
@Override
public FileAnnotation restore(@NotNull VcsAnnotation vcsAnnotation, @NotNull VcsAbstractHistorySession session, @NotNull String annotatedContent, boolean forCurrentRevision, VcsRevisionNumber revisionNumber) {
    final SvnFileAnnotation annotation = new SvnFileAnnotation(myVcs, vcsAnnotation.getFilePath().getVirtualFile(), annotatedContent, revisionNumber);
    final VcsLineAnnotationData basicAnnotation = vcsAnnotation.getBasicAnnotation();
    final VcsLineAnnotationData data = vcsAnnotation.getAdditionalAnnotations().get(MERGED_KEY);
    final Map<VcsRevisionNumber, VcsFileRevision> historyAsMap = session.getHistoryAsMap();
    final Map<VcsRevisionNumber, VcsFileRevision> cachedOtherRevisions = vcsAnnotation.getCachedOtherRevisions();
    for (int i = 0; i < basicAnnotation.getNumLines(); i++) {
        final VcsRevisionNumber revision = basicAnnotation.getRevision(i);
        final VcsRevisionNumber mergedData = data == null ? null : data.getRevision(i);
        final SvnFileRevision fileRevision = (SvnFileRevision) historyAsMap.get(revision);
        if (fileRevision == null)
            return null;
        if (mergedData == null) {
            annotation.setLineInfo(i, fileRevision.getCommitInfo(), null);
        } else {
            final SvnFileRevision mergedRevision = (SvnFileRevision) cachedOtherRevisions.get(mergedData);
            if (mergedRevision == null)
                return null;
            annotation.setLineInfo(i, fileRevision.getCommitInfo(), mergedRevision.getCommitInfo());
        }
    }
    if (vcsAnnotation.getFirstRevision() != null) {
        annotation.setFirstRevision(((SvnRevisionNumber) vcsAnnotation.getFirstRevision()).getRevision());
    }
    for (VcsFileRevision revision : session.getRevisionList()) {
        annotation.setRevision(((SvnRevisionNumber) revision.getRevisionNumber()).getRevision().getNumber(), (SvnFileRevision) revision);
    }
    return annotation;
}
Also used : SvnFileRevision(org.jetbrains.idea.svn.history.SvnFileRevision) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with SvnFileRevision

use of org.jetbrains.idea.svn.history.SvnFileRevision in project intellij-community by JetBrains.

the class SvnAnnotationProvider method annotate.

public FileAnnotation annotate(final VirtualFile file) throws VcsException {
    final SvnDiffProvider provider = (SvnDiffProvider) myVcs.getDiffProvider();
    final SVNRevision currentRevision = ((SvnRevisionNumber) provider.getCurrentRevision(file)).getRevision();
    final VcsRevisionDescription lastChangedRevision = provider.getCurrentRevisionDescription(file);
    if (lastChangedRevision == null) {
        throw new VcsException("Can not get current revision for file " + file.getPath());
    }
    final SVNRevision svnRevision = ((SvnRevisionNumber) lastChangedRevision.getRevisionNumber()).getRevision();
    if (!svnRevision.isValid()) {
        throw new VcsException("Can not get last changed revision for file: " + file.getPath() + "\nPlease run svn info for this file and file an issue.");
    }
    return annotate(file, new SvnFileRevision(myVcs, currentRevision, currentRevision, null, null, null, null, null), lastChangedRevision.getRevisionNumber(), true);
}
Also used : SvnFileRevision(org.jetbrains.idea.svn.history.SvnFileRevision) VcsException(com.intellij.openapi.vcs.VcsException) SVNRevision(org.tmatesoft.svn.core.wc.SVNRevision)

Example 4 with SvnFileRevision

use of org.jetbrains.idea.svn.history.SvnFileRevision in project intellij-community by JetBrains.

the class RepositoryBrowserComponent method getSelectedVcsFile.

@Nullable
public VirtualFile getSelectedVcsFile() {
    final RepositoryTreeNode node = getSelectedNode();
    if (node == null)
        return null;
    DirectoryEntry entry = node.getSVNDirEntry();
    if (entry == null || !entry.isFile()) {
        return null;
    }
    String name = entry.getName();
    FileTypeManager manager = FileTypeManager.getInstance();
    if (entry.getName().lastIndexOf('.') > 0 && !manager.getFileTypeByFileName(name).isBinary()) {
        SVNURL url = node.getURL();
        final SvnFileRevision revision = new SvnFileRevision(myVCS, SVNRevision.UNDEFINED, SVNRevision.HEAD, url.toString(), entry.getAuthor(), entry.getDate(), null, null);
        return new VcsVirtualFile(node.getSVNDirEntry().getName(), revision, VcsFileSystem.getInstance());
    } else {
        return null;
    }
}
Also used : VcsVirtualFile(com.intellij.openapi.vcs.vfs.VcsVirtualFile) SvnFileRevision(org.jetbrains.idea.svn.history.SvnFileRevision) SVNURL(org.tmatesoft.svn.core.SVNURL) FileTypeManager(com.intellij.openapi.fileTypes.FileTypeManager) DirectoryEntry(org.jetbrains.idea.svn.browse.DirectoryEntry) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

SvnFileRevision (org.jetbrains.idea.svn.history.SvnFileRevision)4 Nullable (org.jetbrains.annotations.Nullable)2 FileTypeManager (com.intellij.openapi.fileTypes.FileTypeManager)1 VcsException (com.intellij.openapi.vcs.VcsException)1 VcsVirtualFile (com.intellij.openapi.vcs.vfs.VcsVirtualFile)1 DirectoryEntry (org.jetbrains.idea.svn.browse.DirectoryEntry)1 CommitInfo (org.jetbrains.idea.svn.checkin.CommitInfo)1 SVNURL (org.tmatesoft.svn.core.SVNURL)1 SVNRevision (org.tmatesoft.svn.core.wc.SVNRevision)1