VCS: correctly put "after update" local history label only after text merge conflicts are resolved

also wrap merge text conflict actions into commands to be revertable and better presented in local history
This commit is contained in:
irengrig
2012-07-25 19:56:02 +04:00
parent 38866971ac
commit 93da19c320
3 changed files with 28 additions and 17 deletions
@@ -90,7 +90,12 @@ public interface MergeVersion {
public void applyText(final String text, final Project project) {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
public void run() {
doApplyText(text, project);
CommandProcessor.getInstance().executeCommand(project, new Runnable() {
@Override
public void run() {
doApplyText(text, project);
}
}, "Merge changes", null);
}
});
}
@@ -19,6 +19,7 @@ package com.intellij.openapi.vcs.merge;
import com.intellij.CommonBundle;
import com.intellij.ide.presentation.VirtualFilePresentation;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.diff.ActionButtonPresentation;
import com.intellij.openapi.diff.DiffManager;
import com.intellij.openapi.diff.DiffRequestFactory;
@@ -221,22 +222,27 @@ public class MultipleFileMergeDialog extends DialogWrapper {
final Ref<Exception> ex = new Ref<Exception>();
ApplicationManager.getApplication().runWriteAction(new Runnable() {
public void run() {
try {
if (!(myProvider instanceof MergeProvider2) || myMergeSession.canMerge(file)) {
MergeData data = myProvider.loadRevisions(file);
if (isCurrent) {
file.setBinaryContent(data.CURRENT);
CommandProcessor.getInstance().executeCommand(myProject, new Runnable() {
@Override
public void run() {
try {
if (!(myProvider instanceof MergeProvider2) || myMergeSession.canMerge(file)) {
MergeData data = myProvider.loadRevisions(file);
if (isCurrent) {
file.setBinaryContent(data.CURRENT);
}
else {
file.setBinaryContent(data.LAST);
checkMarkModifiedProject(file);
}
}
markFileProcessed(file, isCurrent ? MergeSession.Resolution.AcceptedYours : MergeSession.Resolution.AcceptedTheirs);
}
else {
file.setBinaryContent(data.LAST);
checkMarkModifiedProject(file);
catch (Exception e) {
ex.set(e);
}
}
markFileProcessed(file, isCurrent ? MergeSession.Resolution.AcceptedYours : MergeSession.Resolution.AcceptedTheirs);
}
catch (Exception e) {
ex.set(e);
}
}, "Accept " + (isCurrent ? "Yours" : "Theirs"), null);
}
});
if (!ex.isNull()) {
@@ -388,9 +388,6 @@ public abstract class AbstractCommonUpdateAction extends AbstractVcsAction {
ProgressManager.progress(VcsBundle.message("progress.text.synchronizing.files"));
doVfsRefresh();
} finally {
if (myProject.isOpen() && (! myProject.isDisposed())) { // not sure
myAfter = LocalHistory.getInstance().putSystemLabel(myProject, "After update");
}
myProjectLevelVcsManager.stopBackgroundVcsOperation();
myProject.getMessageBus().syncPublisher(UpdatedFilesListener.UPDATED_FILES).
consume(UpdatedFilesReverseSide.getPathsFromUpdatedFiles(myUpdatedFiles));
@@ -480,9 +477,12 @@ public abstract class AbstractCommonUpdateAction extends AbstractVcsAction {
final boolean continueChainFinal = continueChain;
final boolean someSessionWasCancelled = wasCanceled || someSessionWasCanceled(myUpdateSessions);
// here text conflicts might be interactively resolved
for (final UpdateSession updateSession : myUpdateSessions) {
updateSession.onRefreshFilesCompleted();
}
// only after conflicts are resolved, put a label
myAfter = LocalHistory.getInstance().putSystemLabel(myProject, "After update");
if (myActionInfo.canChangeFileStatus()) {
final List<VirtualFile> files = new ArrayList<VirtualFile>();