diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchForBaseRevisionTexts.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchForBaseRevisionTexts.java index d1c0e97a1ca3..3e7faf0fd7f5 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchForBaseRevisionTexts.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchForBaseRevisionTexts.java @@ -44,7 +44,7 @@ public class ApplyPatchForBaseRevisionTexts { @NotNull public static ApplyPatchForBaseRevisionTexts create(final Project project, final VirtualFile file, final FilePath pathBeforeRename, final TextFilePatch patch, final Getter baseContents) { - assert ! patch.isNewFile(); // todo check + assert ! patch.isNewFile(); final String beforeVersionId = patch.getBeforeVersionId(); DefaultPatchBaseVersionProvider provider = null; if (beforeVersionId != null) { @@ -81,7 +81,7 @@ public class ApplyPatchForBaseRevisionTexts { return true; } myBase = text; - myPatched = applier.getAfter(); + setPatched(applier.getAfter()); return false; } }, myWarnings); @@ -102,7 +102,7 @@ public class ApplyPatchForBaseRevisionTexts { if (! applier.execute()) { applier.trySolveSomehow(); } - myPatched = applier.getAfter(); + setPatched(applier.getAfter()); return; } @@ -110,7 +110,7 @@ public class ApplyPatchForBaseRevisionTexts { if (! applier.execute()) { applier.trySolveSomehow(); } - myPatched = applier.getAfter(); + setPatched(applier.getAfter()); } public CharSequence getLocal() { @@ -120,6 +120,10 @@ public class ApplyPatchForBaseRevisionTexts { public CharSequence getBase() { return myBase; } + + private void setPatched(final String text) { + myPatched = StringUtil.convertLineSeparators(text); + } public String getPatched() { return myPatched; diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/DefaultPatchBaseVersionProvider.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/DefaultPatchBaseVersionProvider.java index e233756270ca..5685bcfc3123 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/DefaultPatchBaseVersionProvider.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/DefaultPatchBaseVersionProvider.java @@ -27,6 +27,8 @@ import com.intellij.openapi.fileEditor.impl.LoadTextUtil; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Ref; import com.intellij.openapi.vcs.*; +import com.intellij.openapi.vcs.changes.ContentRevision; +import com.intellij.openapi.vcs.diff.DiffProvider; import com.intellij.openapi.vcs.history.*; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.Processor; @@ -79,9 +81,10 @@ public class DefaultPatchBaseVersionProvider { final Matcher matcher = myRevisionPattern.matcher(myVersionId); if (matcher.find()) { revision = myVcs.parseRevisionNumber(matcher.group(1), filePath); + final VcsRevisionNumber finalRevision = revision; + final Boolean[] loadedExactRevision = new Boolean[1]; + if (historyProvider instanceof VcsBaseRevisionAdviser) { - final VcsRevisionNumber finalRevision = revision; - final Boolean[] loadedExactRevision = new Boolean[1]; final boolean success = VcsUtil.runVcsProcessWithProgress(new VcsRunnable() { public void run() throws VcsException { loadedExactRevision[0] = ((VcsBaseRevisionAdviser)historyProvider).getBaseVersionContent(filePath, processor, finalRevision.asString(), warnings); @@ -89,8 +92,22 @@ public class DefaultPatchBaseVersionProvider { }, VcsBundle.message("progress.text2.loading.revision", revision.asString()), true, myProject); // was cancelled if (! success) return; - if (Boolean.TRUE.equals(loadedExactRevision[0])) return; + } else { + // use diff provider + final DiffProvider diffProvider = myVcs.getDiffProvider(); + if (diffProvider != null && filePath.getVirtualFile() != null) { + final ContentRevision fileContent = diffProvider.createFileContent(finalRevision, filePath.getVirtualFile()); + + final boolean success = VcsUtil.runVcsProcessWithProgress(new VcsRunnable() { + public void run() throws VcsException { + loadedExactRevision[0] = ! processor.process(fileContent.getContent()); + } + }, VcsBundle.message("progress.text2.loading.revision", revision.asString()), true, myProject); + // was cancelled + if (! success) return; + } } + if (Boolean.TRUE.equals(loadedExactRevision[0])) return; } }