Search in sources :

Example 6 with MergeData

use of com.intellij.openapi.vcs.merge.MergeData in project intellij-community by JetBrains.

the class CvsMergeProvider method loadRevisions.

@Override
@NotNull
public MergeData loadRevisions(@NotNull VirtualFile file) throws VcsException {
    try {
        final Entry entry = CvsEntriesManager.getInstance().getEntryFor(file);
        final File cvsFile = CvsVfsUtil.getFileFor(file);
        if (entry != null && entry.isResultOfMerge() && entry.isBinary()) {
            final String originalRevision = CvsUtil.getOriginalRevisionForFile(file);
            final MergeData mergeData = new MergeData();
            mergeData.CURRENT = CvsUtil.getStoredContentForFile(file, originalRevision);
            mergeData.LAST = FileUtil.loadFileBytes(cvsFile);
            return mergeData;
        }
        final BufferedInputStream input = new BufferedInputStream(new FileInputStream(cvsFile));
        try {
            final CvsConflictsParser parser = CvsConflictsParser.createOn(input);
            final MergeData mergeData = new MergeData();
            mergeData.ORIGINAL = parser.getCenterVersion().getBytes();
            mergeData.CURRENT = parser.getLeftVersion().getBytes();
            mergeData.LAST = parser.getRightVersion().getBytes();
            return mergeData;
        } finally {
            input.close();
        }
    } catch (IOException e) {
        throw new VcsException(e);
    }
}
Also used : Entry(org.netbeans.lib.cvsclient.admin.Entry) BufferedInputStream(java.io.BufferedInputStream) MergeData(com.intellij.openapi.vcs.merge.MergeData) VcsException(com.intellij.openapi.vcs.VcsException) IOException(java.io.IOException) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) FileInputStream(java.io.FileInputStream) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

MergeData (com.intellij.openapi.vcs.merge.MergeData)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 NotNull (org.jetbrains.annotations.NotNull)5 VcsException (com.intellij.openapi.vcs.VcsException)4 VcsRunnable (com.intellij.vcsUtil.VcsRunnable)3 File (java.io.File)3 IOException (java.io.IOException)3 FilePath (com.intellij.openapi.vcs.FilePath)2 DiffContentFactory (com.intellij.diff.DiffContentFactory)1 DiffRequestProducerException (com.intellij.diff.chains.DiffRequestProducerException)1 DiffContent (com.intellij.diff.contents.DiffContent)1 SimpleDiffRequest (com.intellij.diff.requests.SimpleDiffRequest)1 Ref (com.intellij.openapi.util.Ref)1 AbstractVcs (com.intellij.openapi.vcs.AbstractVcs)1 VfsUtilCore.virtualToIoFile (com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)1 GitFileRevision (git4idea.GitFileRevision)1 GitRevisionNumber (git4idea.GitRevisionNumber)1 BufferedInputStream (java.io.BufferedInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 FileInputStream (java.io.FileInputStream)1