diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchAction.java index 08c553cf8669..b73411c51789 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchAction.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchAction.java @@ -47,7 +47,6 @@ import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.project.DumbAwareAction; import com.intellij.openapi.project.Project; -import com.intellij.openapi.ui.Messages; import com.intellij.openapi.ui.WindowWrapper; import com.intellij.openapi.util.BooleanGetter; import com.intellij.openapi.util.Computable; @@ -306,7 +305,8 @@ public class ApplyPatchAction extends DumbAwareAction { } @NotNull - public static DiffRequest createBadDiffRequest(@NotNull final VirtualFile file, + public static DiffRequest createBadDiffRequest(@Nullable Project project, + @NotNull final VirtualFile file, @NotNull final ApplyPatchForBaseRevisionTexts texts) throws DiffRequestProducerException { if (texts.getLocal() == null) { throw new DiffRequestProducerException("Can't show diff for '" + file.getPresentableUrl() + "'"); @@ -317,10 +317,11 @@ public class ApplyPatchAction extends DumbAwareAction { final List titles = ContainerUtil.list(VcsBundle.message("diff.title.local"), "Patched (with problems)"); final DiffContentFactory contentFactory = DiffContentFactory.getInstance(); - final DocumentContent originalContent = contentFactory.create(texts.getLocal().toString(), file.getFileType()); + DocumentContent localContent = contentFactory.createDocument(project, file); + if (localContent == null) localContent = contentFactory.create(texts.getLocal().toString(), file.getFileType()); final DiffContent mergedContent = contentFactory.create(texts.getPatched(), file.getFileType()); - final List contents = ContainerUtil.list(originalContent, mergedContent); + final List contents = ContainerUtil.list(localContent, mergedContent); final DiffRequest request = new SimpleDiffRequest(windowTitle, contents, titles); DiffUtil.addNotification(new DiffIsApproximateNotification(), request); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/PatchDiffRequestFactory.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/PatchDiffRequestFactory.java index 4eb32f5a2146..485bbfd7513a 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/PatchDiffRequestFactory.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/PatchDiffRequestFactory.java @@ -20,10 +20,8 @@ import com.intellij.diff.chains.DiffRequestProducerException; import com.intellij.diff.contents.DocumentContent; import com.intellij.diff.requests.DiffRequest; import com.intellij.diff.requests.SimpleDiffRequest; -import com.intellij.diff.requests.UnknownFileTypeDiffRequest; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.fileTypes.FileType; -import com.intellij.openapi.fileTypes.UnknownFileType; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Getter; @@ -71,16 +69,17 @@ public class PatchDiffRequestFactory { ApplyPatchForBaseRevisionTexts texts = textsRef.get(); if (texts.getBase() == null) { - return ApplyPatchAction.createBadDiffRequest(file, texts); + return ApplyPatchAction.createBadDiffRequest(project, file, texts); } else { - DiffContentFactory contentFactory = DiffContentFactory.getInstance(); String path = FileUtil.toSystemDependentName(file.getPresentableUrl()); FileType type = file.getFileType(); String windowTitle = VcsBundle.message("patch.apply.conflict.title", path); - DocumentContent localContent = contentFactory.create(texts.getLocal().toString(), type); + DiffContentFactory contentFactory = DiffContentFactory.getInstance(); + DocumentContent localContent = contentFactory.createDocument(project, file); + if (localContent == null) localContent = contentFactory.create(texts.getLocal().toString(), type); DocumentContent baseContent = contentFactory.create(texts.getBase().toString(), type); DocumentContent patchedContent = contentFactory.create(texts.getPatched(), type);