mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
svn: Refactored "BaseMergeTask" and inheritors - code simplified
This commit is contained in:
@@ -24,15 +24,11 @@ import com.intellij.util.continuation.TaskDescriptor;
|
||||
import com.intellij.util.continuation.Where;
|
||||
import org.jetbrains.annotations.CalledInAny;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.idea.svn.SvnUtil;
|
||||
import org.jetbrains.idea.svn.commandLine.SvnBindException;
|
||||
import org.tmatesoft.svn.core.SVNURL;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.intellij.openapi.application.ApplicationManager.getApplication;
|
||||
import static com.intellij.util.containers.ContainerUtil.newArrayList;
|
||||
import static com.intellij.util.containers.ContainerUtil.ar;
|
||||
import static java.util.Collections.singletonList;
|
||||
import static org.jetbrains.idea.svn.WorkingCopyFormat.ONE_DOT_EIGHT;
|
||||
|
||||
@@ -76,11 +72,6 @@ public abstract class BaseMergeTask extends TaskDescriptor {
|
||||
myRunner.next(tasks);
|
||||
}
|
||||
|
||||
@CalledInAny
|
||||
protected void next(@NotNull List<TaskDescriptor> tasks) {
|
||||
myRunner.next(tasks);
|
||||
}
|
||||
|
||||
protected void suspend() {
|
||||
myRunner.suspend();
|
||||
}
|
||||
@@ -90,7 +81,7 @@ public abstract class BaseMergeTask extends TaskDescriptor {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected List<TaskDescriptor> getMergeAllTasks(boolean supportsMergeInfo) {
|
||||
protected TaskDescriptor[] getMergeAllTasks(boolean supportsMergeInfo) {
|
||||
// merge info is not supported - branch copy point is used to make first sync merge successful (without unnecessary tree conflicts)
|
||||
// merge info is supported and svn client < 1.8 - branch copy point is used to determine if sync or reintegrate merge should be performed
|
||||
// merge info is supported and svn client >= 1.8 - branch copy point is not used - svn automatically detects if reintegrate is necessary
|
||||
@@ -100,7 +91,7 @@ public abstract class BaseMergeTask extends TaskDescriptor {
|
||||
: new LookForBranchOriginTask(myMergeProcess, true, copyPoint ->
|
||||
next(new MergeAllWithBranchCopyPointTask(myMergeProcess, copyPoint, supportsMergeInfo)));
|
||||
|
||||
return newArrayList(new LocalChangesPromptTask(myMergeProcess), mergeAllTask);
|
||||
return ar(new LocalChangesPromptTask(myMergeProcess), mergeAllTask);
|
||||
}
|
||||
|
||||
protected void runChangeListsMerge(@NotNull List<CommittedChangeList> lists, @NotNull String title) {
|
||||
@@ -108,20 +99,6 @@ public abstract class BaseMergeTask extends TaskDescriptor {
|
||||
new MergeTask(myMergeProcess, new ChangeListsMergerFactory(lists, false, false, true), title));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected SVNURL parseSourceUrl() {
|
||||
SVNURL result = null;
|
||||
|
||||
try {
|
||||
result = SvnUtil.createUrl(myMergeContext.getSourceUrl());
|
||||
}
|
||||
catch (SvnBindException e) {
|
||||
end(e);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
protected void end() {
|
||||
myRunner.cancelEverything();
|
||||
}
|
||||
|
||||
+2
-10
@@ -15,13 +15,10 @@
|
||||
*/
|
||||
package org.jetbrains.idea.svn.integrate;
|
||||
|
||||
import com.intellij.util.continuation.TaskDescriptor;
|
||||
import com.intellij.util.continuation.Where;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.intellij.util.containers.ContainerUtil.newArrayList;
|
||||
import static com.intellij.util.containers.ContainerUtil.ar;
|
||||
import static org.jetbrains.idea.svn.SvnUtil.checkRepositoryVersion15;
|
||||
|
||||
public class CheckRepositorySupportsMergeInfoTask extends BaseMergeTask {
|
||||
@@ -32,16 +29,11 @@ public class CheckRepositorySupportsMergeInfoTask extends BaseMergeTask {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
next(supportsMergeInfo() ? getChooseMergeTypeTasks() : getMergeAllTasks(false));
|
||||
next(supportsMergeInfo() ? ar(new MergeAllOrSelectedChooserTask(myMergeProcess)) : getMergeAllTasks(false));
|
||||
}
|
||||
|
||||
private boolean supportsMergeInfo() {
|
||||
return myMergeContext.getWcInfo().getFormat().supportsMergeInfo() &&
|
||||
checkRepositoryVersion15(myMergeContext.getVcs(), myMergeContext.getSourceUrl());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private List<TaskDescriptor> getChooseMergeTypeTasks() {
|
||||
return newArrayList(new MergeAllOrSelectedChooserTask(myMergeProcess));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package org.jetbrains.idea.svn.integrate;
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.util.continuation.Where;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.idea.svn.NestedCopyType;
|
||||
@@ -24,6 +25,8 @@ import org.tmatesoft.svn.core.internal.util.SVNURLUtil;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static org.jetbrains.idea.svn.SvnUtil.createUrl;
|
||||
|
||||
public class MergeInitChecksTask extends BaseMergeTask {
|
||||
|
||||
public MergeInitChecksTask(@NotNull QuickMerge mergeProcess) {
|
||||
@@ -31,16 +34,12 @@ public class MergeInitChecksTask extends BaseMergeTask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
SVNURL url = parseSourceUrl();
|
||||
|
||||
if (url != null) {
|
||||
if (areInSameHierarchy(url, myMergeContext.getWcInfo().getUrl())) {
|
||||
end("Cannot merge from self", true);
|
||||
}
|
||||
else if (hasSwitchedRoots() && !myInteraction.shouldContinueSwitchedRootFound()) {
|
||||
end();
|
||||
}
|
||||
public void run() throws VcsException {
|
||||
if (areInSameHierarchy(createUrl(myMergeContext.getSourceUrl()), myMergeContext.getWcInfo().getUrl())) {
|
||||
end("Cannot merge from self", true);
|
||||
}
|
||||
else if (hasSwitchedRoots() && !myInteraction.shouldContinueSwitchedRootFound()) {
|
||||
end();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package org.jetbrains.idea.svn.integrate;
|
||||
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.ChangeListManager;
|
||||
import com.intellij.openapi.vcs.changes.InvokeAfterUpdateMode;
|
||||
import com.intellij.openapi.vcs.changes.LocalChangeList;
|
||||
@@ -24,6 +25,8 @@ import com.intellij.util.continuation.Where;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.tmatesoft.svn.core.SVNURL;
|
||||
|
||||
import static org.jetbrains.idea.svn.SvnUtil.createUrl;
|
||||
|
||||
public class MergeTask extends BaseMergeTask {
|
||||
|
||||
@NotNull private final MergerFactory myFactory;
|
||||
@@ -35,16 +38,12 @@ public class MergeTask extends BaseMergeTask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
SVNURL sourceUrl = parseSourceUrl();
|
||||
public void run() throws VcsException {
|
||||
next(TaskDescriptor.createForBackgroundableTask(newIntegrateTask(createUrl(myMergeContext.getSourceUrl()))));
|
||||
|
||||
if (sourceUrl != null) {
|
||||
next(TaskDescriptor.createForBackgroundableTask(newIntegrateTask(sourceUrl)));
|
||||
|
||||
boolean needRefresh = setupDefaultEmptyChangeListForMerge();
|
||||
if (needRefresh) {
|
||||
refreshChanges();
|
||||
}
|
||||
boolean needRefresh = setupDefaultEmptyChangeListForMerge();
|
||||
if (needRefresh) {
|
||||
refreshChanges();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user