import java.util.List;
+import static com.intellij.openapi.application.ApplicationManager.getApplication;
+import static java.util.Collections.singletonList;
+
public abstract class BaseMergeTask extends TaskDescriptor {
private static final Logger LOG = Logger.getInstance(BaseMergeTask.class);
result = SvnUtil.createUrl(myMergeContext.getSourceUrl());
}
catch (SvnBindException e) {
- finishWithError(context, e.getMessage(), true);
+ end(context, e);
}
return result;
}
@CalledInAny
- protected void finishWithError(@NotNull ContinuationContext context, @NotNull String message, boolean isError) {
+ protected void end(@NotNull ContinuationContext context, @NotNull String message, boolean isError) {
LOG.info((isError ? "Error: " : "Info: ") + message);
- context.next(new TaskDescriptor(message, Where.AWT) {
- @Override
- public void run(ContinuationContext context) {
- myInteraction.showErrors(message, isError);
- context.cancelEverything();
- }
- });
+
+ context.cancelEverything();
+ getApplication().invokeLater(() -> myInteraction.showErrors(message, isError));
}
@CalledInAny
- protected void finishWithError(@NotNull ContinuationContext context, @NotNull String message, @NotNull List<VcsException> exceptions) {
- log(message, exceptions);
-
- context.cancelEverything();
- context.next(new TaskDescriptor(message, Where.AWT) {
- @Override
- public void run(ContinuationContext context) {
- myInteraction.showErrors(message, exceptions);
- }
- });
+ protected void end(@NotNull ContinuationContext context, @NotNull VcsException e) {
+ end(context, myMergeContext.getTitle(), e);
}
- private static void log(@NotNull String message, @NotNull List<VcsException> exceptions) {
- for (VcsException exception : exceptions) {
- LOG.info(message, exception);
- }
+ @CalledInAny
+ protected void end(@NotNull ContinuationContext context, @NotNull String message, @NotNull VcsException e) {
+ LOG.info(message, e);
+
+ context.cancelEverything();
+ getApplication().invokeLater(() -> myInteraction.showErrors(message, singletonList(e)));
}
}
run();
}
catch (VcsException e) {
- context.handleException(e, true);
+ end(context, e);
}
}
result = new MergeCalculatorTask(myMergeProcess);
}
catch (VcsException e) {
- finishWithError(context, e.getMessage(), true);
+ end(context, e);
}
return result;
import com.intellij.util.continuation.Where;
import org.jetbrains.annotations.NotNull;
-import java.util.Collections;
import java.util.concurrent.atomic.AtomicReference;
public class MergeAllWithBranchCopyPointTask extends BaseMergeTask
runMerge(context, inverterValue);
}
else {
- finishWithError(context, "Merge start wasn't found", true);
+ end(context, "Merge start wasn't found", true);
}
}
runMerge(context, inverter);
}
else {
- finishWithError(context, "Merge start wasn't found", true);
+ end(context, "Merge start wasn't found", true);
}
}
catch (VcsException e) {
- finishWithError(context, "Merge start wasn't found", Collections.singletonList(e));
+ end(context, "Merge start wasn't found", e);
}
}
import java.util.concurrent.atomic.AtomicReference;
import static com.intellij.util.containers.ContainerUtil.newArrayList;
-import static java.util.Collections.singletonList;
import static org.jetbrains.idea.svn.SvnUtil.ensureStartSlash;
import static org.tmatesoft.svn.core.internal.util.SVNPathUtil.getRelativePath;
import static org.tmatesoft.svn.core.internal.util.SVNPathUtil.isAncestor;
context.next(new ShowRevisionSelector(myMergeProcess, copyPoint, notMergedChangeLists, myMergeChecker));
}
else {
- finishWithError(context, "Everything is up-to-date", false);
+ end(context, "Everything is up-to-date", false);
}
}
}
result = myCopyData.get().get();
if (result == null) {
- finishWithError(context, "Merge start wasn't found", true);
+ end(context, "Merge start wasn't found", true);
}
}
catch (VcsException e) {
- finishWithError(context, "Merge start wasn't found", singletonList(e));
+ end(context, "Merge start wasn't found", e);
}
return result;
});
}
catch (VcsException e) {
- finishWithError(context, "Checking revisions for merge fault", singletonList(e));
+ end(context, "Checking revisions for merge fault", e);
}
return result;
if (url != null) {
if (areInSameHierarchy(url, myMergeContext.getWcInfo().getUrl())) {
- finishWithError(context, "Cannot merge from self", true);
+ end(context, "Cannot merge from self", true);
}
else if (hasSwitchedRoots() && !myInteraction.shouldContinueSwitchedRootFound()) {
context.cancelEverything();
changedFiles.addAll(getAfterRevisionsFiles(entry.getValue().stream(), true).collect(toList()));
}
catch (IOException e) {
- finishWithError(context, e.getMessage(), true);
+ end(context, new VcsException(e));
}
catch (VcsException e) {
- finishWithError(context, e.getMessage(), true);
+ end(context, e);
}
}