Java Code Examples for com.intellij.openapi.vcs.AbstractVcs#getMergeProvider()
The following examples show how to use
com.intellij.openapi.vcs.AbstractVcs#getMergeProvider() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConflictedDiffRequestPresentable.java From consulo with Apache License 2.0 | 5 votes |
@Override public MyResult step(DiffChainContext context) { if (myChange.getAfterRevision() == null) return createErrorResult(); FileType type = myChange.getVirtualFile() != null ? myChange.getVirtualFile().getFileType() : null; if (myFile.getFileType().isBinary()) { final boolean nowItIsText = ChangeDiffRequestPresentable.checkAssociate(myProject, myFile.getName(), context); if (! nowItIsText) { return createErrorResult(); } } final AbstractVcs vcs = ChangesUtil.getVcsForChange(myChange, myProject); if (vcs == null || vcs.getMergeProvider() == null) { return createErrorResult(); } try { final MergeData mergeData = vcs.getMergeProvider().loadRevisions(myFile); final Charset charset = myFile.getCharset(); final MergeRequest request = DiffRequestFactory.getInstance() .create3WayDiffRequest(CharsetToolkit.bytesToString(mergeData.CURRENT, charset), CharsetToolkit.bytesToString(mergeData.LAST, charset), CharsetToolkit.bytesToString(mergeData.ORIGINAL, charset), type, myProject, null, null); request.setWindowTitle(FileUtil.toSystemDependentName(myFile.getPresentableUrl())); // todo titles? VcsRevisionNumber lastRevisionNumber = mergeData.LAST_REVISION_NUMBER; request.setVersionTitles(new String[]{myChange.getAfterRevision().getRevisionNumber().asString(), "Base Version", lastRevisionNumber != null ? lastRevisionNumber.asString() : ""}); return new MyResult(request, DiffPresentationReturnValue.useRequest); } catch (VcsException e) { LOG.info(e); return createErrorResult(); } }
Example 2
Source File: ChangeForDiffConvertor.java From consulo with Apache License 2.0 | 4 votes |
public DiffRequestPresentable convert(final Change ch, final boolean forceText) { if (ch.hasOtherLayers() && myRecursive) { return new MultipleDiffRequestPresentable(myProject, ch); } if (ChangesUtil.isTextConflictingChange(ch)) { final AbstractVcs vcs = ChangesUtil.getVcsForChange(ch, myProject); final MergeProvider mergeProvider = vcs.getMergeProvider(); if (mergeProvider == null) return null; final FilePath path = ChangesUtil.getFilePath(ch); VirtualFile vf = path.getVirtualFile(); if (vf == null) { path.hardRefresh(); vf = path.getVirtualFile(); } if (vf == null) return null; return new ConflictedDiffRequestPresentable(myProject, vf, ch); } else { if (forceText) { if (ch.getBeforeRevision() != null && ch.getAfterRevision() != null) { try { if (StringUtil.isEmptyOrSpaces(ch.getBeforeRevision().getContent()) && StringUtil.isEmptyOrSpaces(ch.getAfterRevision().getContent())) { return null; } if (StringUtil.equals(ch.getBeforeRevision().getContent(), ch.getAfterRevision().getContent())) { return null; } } catch (VcsException e) { // } } } final ChangeDiffRequestPresentable presentable = new ChangeDiffRequestPresentable(myProject, ch); if (forceText) { presentable.setIgnoreDirectoryFlag(true); } return presentable; } }