svn: Unified quick merge errors displaying

This commit is contained in:
Konstantin Kolosovsky
2016-10-11 04:28:23 +03:00
parent 89feb50e83
commit 140f5965c6
7 changed files with 28 additions and 37 deletions
@@ -31,6 +31,9 @@ import org.tmatesoft.svn.core.SVNURL;
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);
@@ -77,40 +80,30 @@ public abstract class BaseMergeTask extends TaskDescriptor {
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);
protected void end(@NotNull ContinuationContext context, @NotNull VcsException e) {
end(context, myMergeContext.getTitle(), e);
}
@CalledInAny
protected void end(@NotNull ContinuationContext context, @NotNull String message, @NotNull VcsException e) {
LOG.info(message, e);
context.cancelEverything();
context.next(new TaskDescriptor(message, Where.AWT) {
@Override
public void run(ContinuationContext context) {
myInteraction.showErrors(message, exceptions);
}
});
}
private static void log(@NotNull String message, @NotNull List<VcsException> exceptions) {
for (VcsException exception : exceptions) {
LOG.info(message, exception);
}
getApplication().invokeLater(() -> myInteraction.showErrors(message, singletonList(e)));
}
}
@@ -69,7 +69,7 @@ public class LoadRecentBranchRevisions extends BaseMergeTask {
run();
}
catch (VcsException e) {
context.handleException(e, true);
end(context, e);
}
}
@@ -66,7 +66,7 @@ public class MergeAllOrSelectedChooserTask extends BaseMergeTask {
result = new MergeCalculatorTask(myMergeProcess);
}
catch (VcsException e) {
finishWithError(context, e.getMessage(), true);
end(context, e);
}
return result;
@@ -22,7 +22,6 @@ import com.intellij.util.continuation.ContinuationContext;
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
@@ -49,7 +48,7 @@ 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);
}
}
@@ -62,11 +61,11 @@ public class MergeAllWithBranchCopyPointTask extends BaseMergeTask
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);
}
}
@@ -38,7 +38,6 @@ import java.util.List;
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;
@@ -79,7 +78,7 @@ public class MergeCalculatorTask extends BaseMergeTask
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);
}
}
}
@@ -92,11 +91,11 @@ public class MergeCalculatorTask extends BaseMergeTask
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;
@@ -122,7 +121,7 @@ public class MergeCalculatorTask extends BaseMergeTask
});
}
catch (VcsException e) {
finishWithError(context, "Checking revisions for merge fault", singletonList(e));
end(context, "Checking revisions for merge fault", e);
}
return result;
@@ -37,7 +37,7 @@ public class MergeInitChecksTask extends BaseMergeTask {
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();
@@ -71,10 +71,10 @@ public class ShelveLocalChangesTask extends BaseMergeTask {
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);
}
}