mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
svn: Made "LoadRecentBranchRevisions" and "ShowRevisionSelector" extend "BaseMergeTask"
Code simplified
This commit is contained in:
+16
-29
@@ -21,13 +21,9 @@ import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.versionBrowser.ChangeBrowserSettings;
|
||||
import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList;
|
||||
import com.intellij.util.PairConsumer;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.continuation.ContinuationContext;
|
||||
import com.intellij.util.continuation.TaskDescriptor;
|
||||
import com.intellij.util.continuation.Where;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.idea.svn.SvnBundle;
|
||||
import org.jetbrains.idea.svn.history.LogHierarchyNode;
|
||||
import org.jetbrains.idea.svn.history.SvnChangeList;
|
||||
import org.jetbrains.idea.svn.history.SvnCommittedChangesProvider;
|
||||
@@ -36,13 +32,10 @@ import org.jetbrains.idea.svn.mergeinfo.OneShotMergeInfoHelper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: Irina.Chernushina
|
||||
* Date: 3/30/13
|
||||
* Time: 7:40 PM
|
||||
*/
|
||||
public class LoadRecentBranchRevisions extends TaskDescriptor {
|
||||
import static com.intellij.util.containers.ContainerUtil.newArrayList;
|
||||
import static org.jetbrains.idea.svn.SvnBundle.message;
|
||||
|
||||
public class LoadRecentBranchRevisions extends BaseMergeTask {
|
||||
public static final String PROP_BUNCH_SIZE = "idea.svn.quick.merge.bunch.size";
|
||||
private final static int BUNCH_SIZE = 100;
|
||||
private int myBunchSize;
|
||||
@@ -50,15 +43,13 @@ public class LoadRecentBranchRevisions extends TaskDescriptor {
|
||||
private boolean myLastLoaded;
|
||||
private OneShotMergeInfoHelper myHelper;
|
||||
private List<CommittedChangeList> myCommittedChangeLists;
|
||||
@NotNull private final MergeContext myMergeContext;
|
||||
|
||||
public LoadRecentBranchRevisions(@NotNull MergeContext mergeContext, long first) {
|
||||
this(mergeContext, first, -1);
|
||||
public LoadRecentBranchRevisions(@NotNull QuickMerge mergeProcess, long first) {
|
||||
this(mergeProcess, first, -1);
|
||||
}
|
||||
|
||||
public LoadRecentBranchRevisions(@NotNull MergeContext mergeContext, long first, int bunchSize) {
|
||||
super("Loading recent " + mergeContext.getBranchName() + " revisions", Where.POOLED);
|
||||
myMergeContext = mergeContext;
|
||||
public LoadRecentBranchRevisions(@NotNull QuickMerge mergeProcess, long first, int bunchSize) {
|
||||
super(mergeProcess, "Loading recent " + mergeProcess.getMergeContext().getBranchName() + " revisions", Where.POOLED);
|
||||
myFirst = first;
|
||||
|
||||
Integer testBunchSize = Integer.getInteger(PROP_BUNCH_SIZE);
|
||||
@@ -94,28 +85,24 @@ public class LoadRecentBranchRevisions extends TaskDescriptor {
|
||||
settings.USE_CHANGE_BEFORE_FILTER = true;
|
||||
}
|
||||
|
||||
final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
|
||||
ProgressManager.progress2(
|
||||
SvnBundle.message("progress.text2.collecting.history", myMergeContext.getSourceUrl() + (revision > 0 ? ("@" + revision) : "")));
|
||||
final List<Pair<SvnChangeList, LogHierarchyNode>> result = ContainerUtil.newArrayList();
|
||||
ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
|
||||
ProgressManager
|
||||
.progress2(message("progress.text2.collecting.history", myMergeContext.getSourceUrl() + (revision > 0 ? ("@" + revision) : "")));
|
||||
List<Pair<SvnChangeList, LogHierarchyNode>> result = newArrayList();
|
||||
|
||||
((SvnCommittedChangesProvider)myMergeContext.getVcs().getCommittedChangesProvider())
|
||||
.getCommittedChangesWithMergedRevisons(settings, new SvnRepositoryLocation(myMergeContext.getSourceUrl()),
|
||||
myBunchSize + (revision > 0 ? 2 : 1),
|
||||
new PairConsumer<SvnChangeList, LogHierarchyNode>() {
|
||||
public void consume(SvnChangeList svnList, LogHierarchyNode tree) {
|
||||
indicator.setText2(
|
||||
SvnBundle.message("progress.text2.processing.revision", svnList.getNumber()));
|
||||
result.add(Pair.create(svnList, tree));
|
||||
}
|
||||
(list, tree) -> {
|
||||
indicator.setText2(message("progress.text2.processing.revision", list.getNumber()));
|
||||
result.add(Pair.create(list, tree));
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private List<CommittedChangeList> getNotMergedChangeLists(@NotNull List<Pair<SvnChangeList, LogHierarchyNode>> changeLists) {
|
||||
List<CommittedChangeList> result = ContainerUtil.newArrayList();
|
||||
List<CommittedChangeList> result = newArrayList();
|
||||
|
||||
for (Pair<SvnChangeList, LogHierarchyNode> pair : changeLists) {
|
||||
// do not take first since it's equal
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ public class MergeAllOrSelectedChooserTask extends BaseMergeTask {
|
||||
context.next(getMergeAllTasks());
|
||||
break;
|
||||
case showLatest:
|
||||
LoadRecentBranchRevisions loader = new LoadRecentBranchRevisions(myMergeContext, -1);
|
||||
LoadRecentBranchRevisions loader = new LoadRecentBranchRevisions(myMergeProcess, -1);
|
||||
ShowRecentInDialogTask dialog = new ShowRecentInDialogTask(myMergeProcess, loader);
|
||||
|
||||
context.next(loader, dialog);
|
||||
|
||||
@@ -25,7 +25,6 @@ import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.continuation.ContinuationContext;
|
||||
import com.intellij.util.continuation.TaskDescriptor;
|
||||
import com.intellij.util.continuation.Where;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -49,7 +48,6 @@ public class MergeCalculatorTask extends BaseMergeTask
|
||||
|
||||
@NotNull private final AtomicReference<TransparentlyFailedValueI<SvnBranchPointsCalculator.WrapperInvertor, VcsException>> myCopyData;
|
||||
|
||||
@NotNull private final String myMergeTitle;
|
||||
@NotNull private final MergeChecker myMergeChecker;
|
||||
|
||||
@Override
|
||||
@@ -60,7 +58,6 @@ public class MergeCalculatorTask extends BaseMergeTask
|
||||
public MergeCalculatorTask(@NotNull QuickMerge mergeProcess) throws VcsException {
|
||||
super(mergeProcess, "Calculating not merged revisions", Where.POOLED);
|
||||
|
||||
myMergeTitle = "Merge from " + myMergeContext.getBranchName();
|
||||
// TODO: Previously it was configurable - either to use OneShotMergeInfoHelper or BranchInfo as merge checker, but later that logic
|
||||
// TODO: was commented (in 80ebdbfea5210f6c998e67ddf28ca9c670fa4efe on 5/28/2010).
|
||||
// TODO: Still check if we need to preserve such configuration or it is sufficient to always use OneShotMergeInfoHelper.
|
||||
@@ -79,7 +76,7 @@ public class MergeCalculatorTask extends BaseMergeTask
|
||||
List<CommittedChangeList> notMergedChangeLists = getNotMergedChangeLists(afterCopyPointChangeLists);
|
||||
|
||||
if (!notMergedChangeLists.isEmpty()) {
|
||||
context.next(new ShowRevisionSelector(copyPoint, notMergedChangeLists));
|
||||
context.next(new ShowRevisionSelector(myMergeProcess, copyPoint, notMergedChangeLists, myMergeChecker));
|
||||
}
|
||||
else {
|
||||
finishWithError(context, "Everything is up-to-date", false);
|
||||
@@ -163,22 +160,27 @@ public class MergeCalculatorTask extends BaseMergeTask
|
||||
return result;
|
||||
}
|
||||
|
||||
private class ShowRevisionSelector extends TaskDescriptor {
|
||||
private static class ShowRevisionSelector extends BaseMergeTask {
|
||||
|
||||
@NotNull private final List<CommittedChangeList> myChangeLists;
|
||||
@NotNull private final MergeChecker myMergeChecker;
|
||||
@NotNull private final SvnBranchPointsCalculator.WrapperInvertor myCopyPoint;
|
||||
|
||||
private ShowRevisionSelector(@NotNull SvnBranchPointsCalculator.WrapperInvertor copyPoint,
|
||||
@NotNull List<CommittedChangeList> changeLists) {
|
||||
super("show revisions to merge", Where.AWT);
|
||||
private ShowRevisionSelector(@NotNull QuickMerge mergeProcess,
|
||||
@NotNull SvnBranchPointsCalculator.WrapperInvertor copyPoint,
|
||||
@NotNull List<CommittedChangeList> changeLists,
|
||||
@NotNull MergeChecker mergeChecker) {
|
||||
super(mergeProcess, "show revisions to merge", Where.AWT);
|
||||
|
||||
myCopyPoint = copyPoint;
|
||||
myChangeLists = changeLists;
|
||||
myMergeChecker = mergeChecker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(ContinuationContext context) {
|
||||
QuickMergeInteraction.SelectMergeItemsResult result = myInteraction.selectMergeItems(myChangeLists, myMergeTitle, myMergeChecker);
|
||||
QuickMergeInteraction.SelectMergeItemsResult result =
|
||||
myInteraction.selectMergeItems(myChangeLists, myMergeContext.getTitle(), myMergeChecker);
|
||||
|
||||
switch (result.getResultCode()) {
|
||||
case cancel:
|
||||
@@ -191,7 +193,7 @@ public class MergeCalculatorTask extends BaseMergeTask
|
||||
List<CommittedChangeList> lists = result.getSelectedLists();
|
||||
|
||||
if (!lists.isEmpty()) {
|
||||
runChangeListsMerge(context, lists, myCopyPoint, myMergeTitle);
|
||||
runChangeListsMerge(context, lists, myCopyPoint, myMergeContext.getTitle());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -490,7 +490,9 @@ public class ToBeMergedDialog extends DialogWrapper {
|
||||
|
||||
@Override
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
LoadRecentBranchRevisions loader = new LoadRecentBranchRevisions(myMergeContext, myStartNumber, myQuantity);
|
||||
// TODO: Update this not to create new "QuickMerge" instance
|
||||
QuickMerge mergeProcess = new QuickMerge(myMergeContext, new QuickMergeInteractionImpl(myMergeContext));
|
||||
LoadRecentBranchRevisions loader = new LoadRecentBranchRevisions(mergeProcess, myStartNumber, myQuantity);
|
||||
|
||||
try {
|
||||
loader.run();
|
||||
|
||||
Reference in New Issue
Block a user