svn: Refactored "LocalChangesPromptTask" - used callback to run next task

Removed unnecessary "BaseMergeTask.end()" calls
This commit is contained in:
Konstantin Kolosovsky
2016-11-09 23:53:59 +03:00
parent b7eaa8dfac
commit 09f0cc6988
3 changed files with 16 additions and 12 deletions
@@ -93,9 +93,9 @@ public abstract class BaseMergeTask extends TaskDescriptor {
}
protected void merge(@NotNull String title, @NotNull MergerFactory mergerFactory, @Nullable List<SvnChangeList> changeLists) {
next(new LocalChangesPromptTask(myMergeProcess, changeLists),
new MergeTask(myMergeProcess, () ->
newIntegrateTask(title, mergerFactory).queue()));
next(new LocalChangesPromptTask(myMergeProcess, changeLists, () ->
next(new MergeTask(myMergeProcess, () ->
newIntegrateTask(title, mergerFactory).queue()))));
}
@NotNull
@@ -45,10 +45,14 @@ import static org.tmatesoft.svn.core.internal.util.SVNPathUtil.getRelativePath;
public class LocalChangesPromptTask extends BaseMergeTask {
@Nullable private final List<SvnChangeList> myChangeListsToMerge;
@NotNull private final Runnable myCallback;
public LocalChangesPromptTask(@NotNull QuickMerge mergeProcess, @Nullable List<SvnChangeList> changeListsToMerge) {
public LocalChangesPromptTask(@NotNull QuickMerge mergeProcess,
@Nullable List<SvnChangeList> changeListsToMerge,
@NotNull Runnable callback) {
super(mergeProcess, "local changes intersection check", Where.AWT);
myChangeListsToMerge = changeListsToMerge;
myCallback = callback;
}
@Nullable
@@ -75,18 +79,16 @@ public class LocalChangesPromptTask extends BaseMergeTask {
switch (nextAction) {
case continueMerge:
myCallback.run();
break;
case shelve:
next(new ShelveLocalChangesTask(myMergeProcess, intersection));
break;
case cancel:
end();
next(new ShelveLocalChangesTask(myMergeProcess, intersection, myCallback));
break;
case inspect:
List<FilePath> intersectedPaths = sorted(getPaths(intersection.getAllChanges()), FilePathByPathComparator.getInstance());
myInteraction.showIntersectedLocalPaths(intersectedPaths);
end();
break;
case cancel:
break;
}
}
@@ -31,17 +31,19 @@ import static com.intellij.openapi.application.ApplicationManager.getApplication
public class ShelveLocalChangesTask extends BaseMergeTask {
@NotNull private final Intersection myIntersection;
@NotNull private final Runnable myCallback;
public ShelveLocalChangesTask(@NotNull QuickMerge mergeProcess, @NotNull Intersection intersection) {
public ShelveLocalChangesTask(@NotNull QuickMerge mergeProcess, @NotNull Intersection intersection, @NotNull Runnable callback) {
super(mergeProcess, "Shelving local changes before merge", Where.POOLED);
myIntersection = intersection;
myCallback = callback;
}
@Override
public void run() throws VcsException {
try {
shelveChanges();
myCallback.run();
}
catch (IOException e) {
throw new VcsException(e);