mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
vcs: allow to modify local content in diff for "Patch applied with conflicts" case
* local content is editable for "Patch applied" case.
This commit is contained in:
@@ -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<String> 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<DiffContent> contents = ContainerUtil.list(originalContent, mergedContent);
|
||||
final List<DiffContent> contents = ContainerUtil.list(localContent, mergedContent);
|
||||
|
||||
final DiffRequest request = new SimpleDiffRequest(windowTitle, contents, titles);
|
||||
DiffUtil.addNotification(new DiffIsApproximateNotification(), request);
|
||||
|
||||
+4
-5
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user