mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
apply patch: when revision number is specified, try to load base revision contents by number first (don't know why we didn't)
This commit is contained in:
+8
-4
@@ -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<CharSequence> 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;
|
||||
|
||||
+20
-3
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user