本文整理汇总了Java中com.intellij.openapi.vcs.AbstractVcs.getMergeProvider方法的典型用法代码示例。如果您正苦于以下问题:Java AbstractVcs.getMergeProvider方法的具体用法?Java AbstractVcs.getMergeProvider怎么用?Java AbstractVcs.getMergeProvider使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.vcs.AbstractVcs
的用法示例。
在下文中一共展示了AbstractVcs.getMergeProvider方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convert
import com.intellij.openapi.vcs.AbstractVcs; //导入方法依赖的package包/类
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);
if (vcs == null || vcs.getMergeProvider() == null) return null;
final FilePath path = ChangesUtil.getFilePath(ch);
VirtualFile vf = path.getVirtualFile();
if (vf == null) {
vf = LocalFileSystem.getInstance().refreshAndFindFileByPath(path.getPath());
}
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;
}
}
示例2: step
import com.intellij.openapi.vcs.AbstractVcs; //导入方法依赖的package包/类
@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();
}
}