mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
SVN: one-click merge/integrate to branch: correctly process merge cancellation (if stopped in the middle, do not take next changelist)
(cherry picked from commit 835ed1c8c9b3d8620ff04c3979c44c9b8c428cf3)
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.jetbrains.idea.svn.dialogs;
|
||||
|
||||
import com.intellij.util.NotNullFunction;
|
||||
import com.intellij.util.Consumer;
|
||||
import org.jetbrains.idea.svn.SvnConfiguration;
|
||||
import org.jetbrains.idea.svn.SvnVcs;
|
||||
import org.jetbrains.idea.svn.integrate.IMerger;
|
||||
@@ -87,7 +87,7 @@ public class BranchMerger implements IMerger {
|
||||
}
|
||||
}
|
||||
|
||||
public void getInfo(NotNullFunction<String, Boolean> holder, boolean getLatest) {
|
||||
public void getInfo(Consumer<String> holder, boolean getLatest) {
|
||||
}
|
||||
|
||||
public File getMergeInfoHolder() {
|
||||
@@ -96,4 +96,7 @@ public class BranchMerger implements IMerger {
|
||||
|
||||
public void afterProcessing() {
|
||||
}
|
||||
|
||||
public void getSkipped(Consumer<String> holder) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.jetbrains.idea.svn.integrate;
|
||||
|
||||
import com.intellij.util.NotNullFunction;
|
||||
import com.intellij.util.Consumer;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.tmatesoft.svn.core.SVNException;
|
||||
|
||||
@@ -24,7 +24,8 @@ import java.io.File;
|
||||
public interface IMerger {
|
||||
boolean hasNext();
|
||||
void mergeNext() throws SVNException;
|
||||
void getInfo(NotNullFunction<String, Boolean> holder, boolean getLatest);
|
||||
void getInfo(Consumer<String> holder, boolean getLatest);
|
||||
void getSkipped(final Consumer<String> holder);
|
||||
String getComment();
|
||||
@Nullable
|
||||
File getMergeInfoHolder();
|
||||
|
||||
@@ -19,7 +19,7 @@ import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList;
|
||||
import com.intellij.util.NotNullFunction;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.messages.Topic;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -137,16 +137,16 @@ public class Merger implements IMerger {
|
||||
Collections.<CommittedChangeList>emptyList();
|
||||
}
|
||||
|
||||
public void getInfo(final NotNullFunction<String, Boolean> holder, final boolean getLatest) {
|
||||
public void getInfo(final Consumer<String> holder, final boolean getLatest) {
|
||||
if (getLatest && (myLatestProcessed != null)) {
|
||||
holder.fun(SvnBundle.message("action.Subversion.integrate.changes.warning.failed.list.text", myLatestProcessed.getNumber(),
|
||||
holder.consume(SvnBundle.message("action.Subversion.integrate.changes.warning.failed.list.text", myLatestProcessed.getNumber(),
|
||||
myLatestProcessed.getComment().replace('\n', '|')));
|
||||
}
|
||||
|
||||
getSkipped(holder);
|
||||
}
|
||||
|
||||
private void getSkipped(final NotNullFunction<String, Boolean> holder) {
|
||||
public void getSkipped(final Consumer<String> holder) {
|
||||
final List<CommittedChangeList> tail = getTail();
|
||||
if (! tail.isEmpty()) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
@@ -158,7 +158,7 @@ public class Merger implements IMerger {
|
||||
sb.append(list.getNumber()).append(" (").append(list.getComment().replace('\n', '|')).append(')');
|
||||
}
|
||||
|
||||
holder.fun(SvnBundle.message("action.Subversion.integrate.changes.warning.skipped.lists.text", sb.toString()));
|
||||
holder.consume(SvnBundle.message("action.Subversion.integrate.changes.warning.skipped.lists.text", sb.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+44
-34
@@ -21,6 +21,7 @@ import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vcs.*;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import com.intellij.openapi.vcs.changes.ChangeListManager;
|
||||
@@ -30,7 +31,6 @@ import com.intellij.openapi.vcs.changes.ui.CommitChangeListDialog;
|
||||
import com.intellij.openapi.vcs.ex.ProjectLevelVcsManagerEx;
|
||||
import com.intellij.openapi.vcs.update.*;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.NotNullFunction;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.idea.svn.*;
|
||||
@@ -44,6 +44,7 @@ import org.tmatesoft.svn.core.wc.SVNStatusType;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class SvnIntegrateChangesTask extends Task.Backgroundable {
|
||||
@@ -111,11 +112,6 @@ public class SvnIntegrateChangesTask extends Task.Backgroundable {
|
||||
|
||||
// try to do multiple under single progress
|
||||
while (true) {
|
||||
if (indicator.isCanceled()) {
|
||||
createMessage(false, true, SvnBundle.message("action.Subversion.integrate.changes.message.canceled.text"));
|
||||
return;
|
||||
}
|
||||
|
||||
doMerge();
|
||||
|
||||
RefreshVFsSynchronously.updateAllChanged(myRecentlyUpdatedFiles);
|
||||
@@ -135,11 +131,9 @@ public class SvnIntegrateChangesTask extends Task.Backgroundable {
|
||||
private void createMessage(final boolean getLatest, final boolean warning, final String firstString) {
|
||||
final List<String> messages = new ArrayList<String>();
|
||||
messages.add(firstString);
|
||||
myMerger.getInfo(new NotNullFunction<String, Boolean>() {
|
||||
@NotNull
|
||||
public Boolean fun(final String s) {
|
||||
myMerger.getInfo(new Consumer<String>() {
|
||||
public void consume(final String s) {
|
||||
messages.add(s);
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
}, getLatest);
|
||||
final VcsException result = new VcsException(messages);
|
||||
@@ -156,28 +150,28 @@ public class SvnIntegrateChangesTask extends Task.Backgroundable {
|
||||
}
|
||||
|
||||
public void onCancel() {
|
||||
onSuccess();
|
||||
try {
|
||||
if (myProject.isDisposed()) return;
|
||||
afterExecution(true);
|
||||
} finally {
|
||||
BlockReloadingUtil.unblock();
|
||||
}
|
||||
}
|
||||
|
||||
public void onSuccess() {
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
if (myProject.isDisposed()) return;
|
||||
afterExecution();
|
||||
} finally {
|
||||
BlockReloadingUtil.unblock();
|
||||
}
|
||||
}
|
||||
try {
|
||||
if (myProject.isDisposed()) return;
|
||||
afterExecution(false);
|
||||
} finally {
|
||||
BlockReloadingUtil.unblock();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private void accomulate() {
|
||||
myAccomulatedFiles.accomulateFiles(myRecentlyUpdatedFiles, UpdatedFilesReverseSide.DuplicateLevel.DUPLICATE_ERRORS);
|
||||
}
|
||||
|
||||
private void afterExecution() {
|
||||
private void afterExecution(final boolean wasCanceled) {
|
||||
if (! myRecentlyUpdatedFiles.isEmpty()) {
|
||||
myResolveWorker.execute(myRecentlyUpdatedFiles);
|
||||
}
|
||||
@@ -185,9 +179,9 @@ public class SvnIntegrateChangesTask extends Task.Backgroundable {
|
||||
|
||||
accomulate();
|
||||
|
||||
if ((! myMerger.hasNext()) || haveConflicts || (! myExceptions.isEmpty()) || myAccomulatedFiles.containErrors()) {
|
||||
if ((! myMerger.hasNext()) || haveConflicts || (! myExceptions.isEmpty()) || myAccomulatedFiles.containErrors() || wasCanceled) {
|
||||
initMergeTarget();
|
||||
if (myAccomulatedFiles.isEmpty() && myExceptions.isEmpty() && (myMergeTarget == null)) {
|
||||
if (myAccomulatedFiles.isEmpty() && myExceptions.isEmpty() && (myMergeTarget == null) && (! wasCanceled)) {
|
||||
Messages.showMessageDialog(SvnBundle.message("action.Subversion.integrate.changes.message.files.up.to.date.text"), myTitle,
|
||||
Messages.getInformationIcon());
|
||||
} else {
|
||||
@@ -196,7 +190,21 @@ public class SvnIntegrateChangesTask extends Task.Backgroundable {
|
||||
exception.setIsWarning(true);
|
||||
myExceptions.add(exception);
|
||||
}
|
||||
finishActions();
|
||||
if (wasCanceled) {
|
||||
final List<String> details = new LinkedList<String>();
|
||||
details.add("Integration was canceled");
|
||||
myMerger.getSkipped(new Consumer<String>() {
|
||||
public void consume(String s) {
|
||||
if (! StringUtil.isEmptyOrSpaces(s)) {
|
||||
details.add(s);
|
||||
}
|
||||
}
|
||||
});
|
||||
final VcsException exception = new VcsException(details);
|
||||
exception.setIsWarning(true);
|
||||
myExceptions.add(exception);
|
||||
}
|
||||
finishActions(wasCanceled);
|
||||
}
|
||||
myMerger.afterProcessing();
|
||||
} else {
|
||||
@@ -204,15 +212,17 @@ public class SvnIntegrateChangesTask extends Task.Backgroundable {
|
||||
}
|
||||
}
|
||||
|
||||
private void finishActions() {
|
||||
if ((! myDryRun) && (myExceptions.isEmpty()) && (! myAccomulatedFiles.containErrors()) &&
|
||||
((! myAccomulatedFiles.isEmpty()) || (myMergeTarget != null))) {
|
||||
if (myInfo.isUnderProjectRoot()) {
|
||||
showLocalCommit();
|
||||
} else {
|
||||
showAlienCommit();
|
||||
private void finishActions(final boolean wasCanceled) {
|
||||
if (! wasCanceled) {
|
||||
if ((! myDryRun) && (myExceptions.isEmpty()) && (! myAccomulatedFiles.containErrors()) &&
|
||||
((! myAccomulatedFiles.isEmpty()) || (myMergeTarget != null))) {
|
||||
if (myInfo.isUnderProjectRoot()) {
|
||||
showLocalCommit();
|
||||
} else {
|
||||
showAlienCommit();
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
prepareAndShowResults();
|
||||
@@ -234,7 +244,7 @@ public class SvnIntegrateChangesTask extends Task.Backgroundable {
|
||||
}
|
||||
}
|
||||
if (! myExceptions.isEmpty()) {
|
||||
AbstractVcsHelper.getInstance(myProject).showErrors(myExceptions, VcsBundle.message("message.title.vcs.update.errors"));
|
||||
AbstractVcsHelper.getInstance(myProject).showErrors(myExceptions, VcsBundle.message("message.title.vcs.update.errors", myExceptions.size()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user