IDEA-62649 SVN Revert: Says "Subversion Rollback" in Progress Window

This commit is contained in:
irengrig
2012-07-25 17:01:54 +04:00
parent 1b36f27a9b
commit 38866971ac
6 changed files with 61 additions and 47 deletions
@@ -42,6 +42,7 @@ import com.intellij.openapi.vcs.changes.*;
import com.intellij.openapi.vcs.changes.patch.ApplyPatchDefaultExecutor;
import com.intellij.openapi.vcs.changes.patch.PatchFileType;
import com.intellij.openapi.vcs.changes.patch.PatchNameChecker;
import com.intellij.openapi.vcs.changes.ui.RollbackChangesDialog;
import com.intellij.openapi.vcs.changes.ui.RollbackWorker;
import com.intellij.openapi.vfs.CharsetToolkit;
import com.intellij.openapi.vfs.VirtualFile;
@@ -52,6 +53,7 @@ import com.intellij.util.continuation.*;
import com.intellij.util.messages.MessageBus;
import com.intellij.util.messages.Topic;
import com.intellij.util.text.CharArrayCharSequence;
import com.intellij.util.ui.UIUtil;
import com.intellij.vcsUtil.FilesProgress;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
@@ -188,7 +190,8 @@ public class ShelveChangesManager implements ProjectComponent, JDOMExternalizabl
ProgressManager.checkCanceled();
if (rollback) {
new RollbackWorker(myProject, false).doRollback(changes, true, null, VcsBundle.message("shelve.changes.action"));
final String operationName = UIUtil.removeMnemonic(RollbackChangesDialog.operationNameByChanges(myProject, changes));
new RollbackWorker(myProject, operationName).doRollback(changes, true, null, VcsBundle.message("shelve.changes.action"));
}
}
finally {
@@ -44,6 +44,7 @@ public class RollbackChangesDialog extends DialogWrapper {
private final ChangeInfoCalculator myInfoCalculator;
private final CommitLegendPanel myCommitLegendPanel;
private Runnable myListChangeListener;
private String myOperationName;
public static void rollbackChanges(final Project project, final Collection<Change> changes) {
rollbackChanges(project, changes, true);
@@ -100,22 +101,13 @@ public class RollbackChangesDialog extends DialogWrapper {
};
myBrowser = new MultipleChangeListBrowser(project, changeLists, changes, null, true, true, myListChangeListener, myListChangeListener);
Set<AbstractVcs> affectedVcs = new HashSet<AbstractVcs>();
for (Change c : changes) {
final AbstractVcs vcs = ChangesUtil.getVcsForChange(c, project);
if (vcs != null) {
// vcs may be null if we have turned off VCS integration and are in process of refreshing
affectedVcs.add(vcs);
}
}
myOperationName = operationNameByChanges(project, changes);
setOKButtonText(myOperationName);
String operationName = RollbackUtil.getRollbackOperationName(affectedVcs);
setOKButtonText(operationName);
operationName = UIUtil.removeMnemonic(operationName);
setTitle(VcsBundle.message("changes.action.rollback.custom.title", operationName));
myOperationName = UIUtil.removeMnemonic(myOperationName);
setTitle(VcsBundle.message("changes.action.rollback.custom.title", myOperationName));
setCancelButtonText(CommonBundle.getCloseButtonText());
myBrowser.setToggleActionTitle("Include in " + operationName.toLowerCase());
myBrowser.setToggleActionTitle("Include in " + myOperationName.toLowerCase());
for (Change c : changes) {
if (c.getType() == Change.Type.NEW) {
@@ -128,6 +120,19 @@ public class RollbackChangesDialog extends DialogWrapper {
myListChangeListener.run();
}
public static String operationNameByChanges(Project project, Collection<Change> changes) {
Set<AbstractVcs> affectedVcs = new HashSet<AbstractVcs>();
for (Change c : changes) {
final AbstractVcs vcs = ChangesUtil.getVcsForChange(c, project);
if (vcs != null) {
// vcs may be null if we have turned off VCS integration and are in process of refreshing
affectedVcs.add(vcs);
}
}
return RollbackUtil.getRollbackOperationName(affectedVcs);
}
@Override
protected void dispose() {
super.dispose();
@@ -137,7 +142,7 @@ public class RollbackChangesDialog extends DialogWrapper {
@Override
protected void doOKAction() {
super.doOKAction();
new RollbackWorker(myProject, myRefreshSynchronously).doRollback(myBrowser.getChangesIncludedInAllLists(),
new RollbackWorker(myProject, myOperationName).doRollback(myBrowser.getChangesIncludedInAllLists(),
myDeleteLocallyAddedFiles != null && myDeleteLocallyAddedFiles.isSelected(),
myAfterVcsRefreshInAwt, null);
}
@@ -24,8 +24,10 @@ import com.intellij.openapi.progress.*;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vcs.*;
import com.intellij.openapi.vcs.changes.*;
import com.intellij.openapi.vcs.rollback.DefaultRollbackEnvironment;
import com.intellij.openapi.vcs.rollback.RollbackEnvironment;
import com.intellij.openapi.vcs.update.RefreshVFsSynchronously;
import com.intellij.util.WaitForProgressToShow;
@@ -39,10 +41,16 @@ import java.util.List;
public class RollbackWorker {
private final Project myProject;
private final String myOperationName;
private final List<VcsException> myExceptions;
public RollbackWorker(final Project project, final boolean synchronous/*todo[irengrig] and what?*/) {
public RollbackWorker(final Project project) {
this(project, DefaultRollbackEnvironment.ROLLBACK_OPERATION_NAME);
}
public RollbackWorker(final Project project, final String operationName) {
myProject = project;
myOperationName = operationName;
myExceptions = new ArrayList<VcsException>(0);
}
@@ -69,7 +77,7 @@ public class RollbackWorker {
if (ApplicationManager.getApplication().isDispatchThread()) {
ProgressManager.getInstance()
.run(new Task.Backgroundable(myProject, VcsBundle.message("changes.action.rollback.text"), true,
.run(new Task.Backgroundable(myProject, myOperationName, true,
new PerformInBackgroundOption() {
public boolean shouldStartInBackground() {
return VcsConfiguration.getInstance(myProject).PERFORM_ROLLBACK_IN_BACKGROUND;
@@ -128,7 +136,7 @@ public class RollbackWorker {
changesToRefresh.addAll(changes);
if (myIndicator != null) {
myIndicator.setText(vcs.getDisplayName() + ": performing rollback...");
myIndicator.setText(vcs.getDisplayName() + ": performing " + StringUtil.toLowerCase(myOperationName) + "...");
myIndicator.setIndeterminate(false);
myIndicator.checkCanceled();
}
@@ -157,19 +165,17 @@ public class RollbackWorker {
}
doRefresh(myProject, changesToRefresh);
AbstractVcsHelper.getInstance(myProject).showErrors(myExceptions, VcsBundle.message("changes.action.rollback.text"));
AbstractVcsHelper.getInstance(myProject).showErrors(myExceptions, myOperationName);
}
private void doRefresh(final Project project, final List<Change> changesToRefresh) {
final String actionName = VcsBundle.message("changes.action.rollback.text");
final LocalHistoryAction action = LocalHistory.getInstance().startAction(actionName);
final LocalHistoryAction action = LocalHistory.getInstance().startAction(myOperationName);
final Runnable forAwtThread = new Runnable() {
public void run() {
action.finish();
LocalHistory.getInstance().putSystemLabel(myProject, (myLocalHistoryActionName == null) ?
actionName : myLocalHistoryActionName, -1);
myOperationName : myLocalHistoryActionName, -1);
final VcsDirtyScopeManager manager = PeriodicalTasksCloser.getInstance().safeGetComponent(project, VcsDirtyScopeManager.class);
for (Change change : changesToRefresh) {
final ContentRevision beforeRevision = change.getBeforeRevision();
@@ -22,11 +22,11 @@ import com.intellij.openapi.vcs.changes.Change;
import com.intellij.openapi.vcs.changes.ChangeListManager;
import com.intellij.openapi.vcs.changes.ChangeListManagerImpl;
import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager;
import com.intellij.testFramework.vcs.DuringChangeListManagerUpdateTestScheme;
import com.intellij.openapi.vcs.changes.ui.RollbackWorker;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.testFramework.vcs.DuringChangeListManagerUpdateTestScheme;
import org.jetbrains.annotations.Nullable;
import org.junit.Assert;
import org.junit.Test;
@@ -82,7 +82,7 @@ public class SvnChangesCorrectlyRefreshedTest extends SvnTestCase {
final Collection<Change> changes = clManager.getDefaultChangeList().getChanges();
final RollbackWorker worker = new RollbackWorker(myProject, true);
final RollbackWorker worker = new RollbackWorker(myProject);
worker.doRollback(changes, false, null, null);
final CharSequence text = LoadTextUtil.loadText(subTree.myS1File);
@@ -110,7 +110,7 @@ public class SvnChangesCorrectlyRefreshedTest extends SvnTestCase {
final Collection<Change> changes = clManager.getDefaultChangeList().getChanges();
final RollbackWorker worker = new RollbackWorker(myProject, true);
final RollbackWorker worker = new RollbackWorker(myProject);
worker.doRollback(changes, false, null, null);
assertVF(subTree.mySourceDir, "s1.txt");
@@ -135,7 +135,7 @@ public class SvnChangesCorrectlyRefreshedTest extends SvnTestCase {
final Collection<Change> changes = clManager.getDefaultChangeList().getChanges();
final RollbackWorker worker = new RollbackWorker(myProject, true);
final RollbackWorker worker = new RollbackWorker(myProject);
worker.doRollback(changes, false, null, null);
assertVF(subTree.mySourceDir, "s1.txt");
@@ -164,7 +164,7 @@ public class SvnChangesCorrectlyRefreshedTest extends SvnTestCase {
final Collection<Change> changes = clManager.getDefaultChangeList().getChanges();
final RollbackWorker worker = new RollbackWorker(myProject, true);
final RollbackWorker worker = new RollbackWorker(myProject);
worker.doRollback(changes, false, null, null);
subTree.mySourceDir = assertVF(subTree.myRootDir, "source");
@@ -197,7 +197,7 @@ public class SvnChangesCorrectlyRefreshedTest extends SvnTestCase {
final Collection<Change> changes = clManager.getDefaultChangeList().getChanges();
final RollbackWorker worker = new RollbackWorker(myProject, true);
final RollbackWorker worker = new RollbackWorker(myProject);
worker.doRollback(changes, false, null, null);
subTree.mySourceDir = assertVF(subTree.myRootDir, "source");
@@ -224,7 +224,7 @@ public class SvnChangesCorrectlyRefreshedTest extends SvnTestCase {
final Collection<Change> changes = clManager.getDefaultChangeList().getChanges();
final RollbackWorker worker = new RollbackWorker(myProject, true);
final RollbackWorker worker = new RollbackWorker(myProject);
worker.doRollback(changes, false, null, null);
assertVF(subTree.myRootDir, "source");
@@ -262,7 +262,7 @@ public class SvnChangesCorrectlyRefreshedTest extends SvnTestCase {
final Collection<Change> changes = clManager.getDefaultChangeList().getChanges();
final RollbackWorker worker = new RollbackWorker(myProject, true);
final RollbackWorker worker = new RollbackWorker(myProject);
worker.doRollback(changes, false, null, null);
assertVF(subTree.myRootDir, "source");
@@ -22,11 +22,11 @@ import com.intellij.openapi.vcs.changes.Change;
import com.intellij.openapi.vcs.changes.ChangeListManager;
import com.intellij.openapi.vcs.changes.ChangeListManagerImpl;
import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager;
import com.intellij.testFramework.vcs.DuringChangeListManagerUpdateTestScheme;
import com.intellij.openapi.vcs.changes.ui.RollbackWorker;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.testFramework.vcs.DuringChangeListManagerUpdateTestScheme;
import org.jetbrains.annotations.Nullable;
import org.junit.Assert;
import org.junit.Test;
@@ -110,7 +110,7 @@ public class SvnChangesCorrectlyRefreshedTest extends SvnTestCase {
final Collection<Change> changes = clManager.getDefaultChangeList().getChanges();
final RollbackWorker worker = new RollbackWorker(myProject, true);
final RollbackWorker worker = new RollbackWorker(myProject);
worker.doRollback(changes, false, null, null);
final CharSequence text = LoadTextUtil.loadText(subTree.myS1File);
@@ -138,7 +138,7 @@ public class SvnChangesCorrectlyRefreshedTest extends SvnTestCase {
final Collection<Change> changes = clManager.getDefaultChangeList().getChanges();
final RollbackWorker worker = new RollbackWorker(myProject, true);
final RollbackWorker worker = new RollbackWorker(myProject);
worker.doRollback(changes, false, null, null);
assertVF(subTree.mySourceDir, "s1.txt");
@@ -163,7 +163,7 @@ public class SvnChangesCorrectlyRefreshedTest extends SvnTestCase {
final Collection<Change> changes = clManager.getDefaultChangeList().getChanges();
final RollbackWorker worker = new RollbackWorker(myProject, true);
final RollbackWorker worker = new RollbackWorker(myProject);
worker.doRollback(changes, false, null, null);
assertVF(subTree.mySourceDir, "s1.txt");
@@ -192,7 +192,7 @@ public class SvnChangesCorrectlyRefreshedTest extends SvnTestCase {
final Collection<Change> changes = clManager.getDefaultChangeList().getChanges();
final RollbackWorker worker = new RollbackWorker(myProject, true);
final RollbackWorker worker = new RollbackWorker(myProject);
worker.doRollback(changes, false, null, null);
subTree.mySourceDir = assertVF(subTree.myRootDir, "source");
@@ -225,7 +225,7 @@ public class SvnChangesCorrectlyRefreshedTest extends SvnTestCase {
final Collection<Change> changes = clManager.getDefaultChangeList().getChanges();
final RollbackWorker worker = new RollbackWorker(myProject, true);
final RollbackWorker worker = new RollbackWorker(myProject);
worker.doRollback(changes, false, null, null);
subTree.mySourceDir = assertVF(subTree.myRootDir, "source");
@@ -252,7 +252,7 @@ public class SvnChangesCorrectlyRefreshedTest extends SvnTestCase {
final Collection<Change> changes = clManager.getDefaultChangeList().getChanges();
final RollbackWorker worker = new RollbackWorker(myProject, true);
final RollbackWorker worker = new RollbackWorker(myProject);
worker.doRollback(changes, false, null, null);
assertVF(subTree.myRootDir, "source");
@@ -290,7 +290,7 @@ public class SvnChangesCorrectlyRefreshedTest extends SvnTestCase {
final Collection<Change> changes = clManager.getDefaultChangeList().getChanges();
final RollbackWorker worker = new RollbackWorker(myProject, true);
final RollbackWorker worker = new RollbackWorker(myProject);
worker.doRollback(changes, false, null, null);
assertVF(subTree.myRootDir, "source");
@@ -110,7 +110,7 @@ public class SvnChangesCorrectlyRefreshedTest extends SvnTestCase {
final Collection<Change> changes = clManager.getDefaultChangeList().getChanges();
final RollbackWorker worker = new RollbackWorker(myProject, true);
final RollbackWorker worker = new RollbackWorker(myProject);
worker.doRollback(changes, false, null, null);
final CharSequence text = LoadTextUtil.loadText(subTree.myS1File);
@@ -138,7 +138,7 @@ public class SvnChangesCorrectlyRefreshedTest extends SvnTestCase {
final Collection<Change> changes = clManager.getDefaultChangeList().getChanges();
final RollbackWorker worker = new RollbackWorker(myProject, true);
final RollbackWorker worker = new RollbackWorker(myProject);
worker.doRollback(changes, false, null, null);
assertVF(subTree.mySourceDir, "s1.txt");
@@ -163,7 +163,7 @@ public class SvnChangesCorrectlyRefreshedTest extends SvnTestCase {
final Collection<Change> changes = clManager.getDefaultChangeList().getChanges();
final RollbackWorker worker = new RollbackWorker(myProject, true);
final RollbackWorker worker = new RollbackWorker(myProject);
worker.doRollback(changes, false, null, null);
assertVF(subTree.mySourceDir, "s1.txt");
@@ -192,7 +192,7 @@ public class SvnChangesCorrectlyRefreshedTest extends SvnTestCase {
final Collection<Change> changes = clManager.getDefaultChangeList().getChanges();
final RollbackWorker worker = new RollbackWorker(myProject, true);
final RollbackWorker worker = new RollbackWorker(myProject);
worker.doRollback(changes, false, null, null);
subTree.mySourceDir = assertVF(subTree.myRootDir, "source");
@@ -225,7 +225,7 @@ public class SvnChangesCorrectlyRefreshedTest extends SvnTestCase {
final Collection<Change> changes = clManager.getDefaultChangeList().getChanges();
final RollbackWorker worker = new RollbackWorker(myProject, true);
final RollbackWorker worker = new RollbackWorker(myProject);
worker.doRollback(changes, false, null, null);
subTree.mySourceDir = assertVF(subTree.myRootDir, "source");
@@ -252,7 +252,7 @@ public class SvnChangesCorrectlyRefreshedTest extends SvnTestCase {
final Collection<Change> changes = clManager.getDefaultChangeList().getChanges();
final RollbackWorker worker = new RollbackWorker(myProject, true);
final RollbackWorker worker = new RollbackWorker(myProject);
worker.doRollback(changes, false, null, null);
assertVF(subTree.myRootDir, "source");
@@ -290,7 +290,7 @@ public class SvnChangesCorrectlyRefreshedTest extends SvnTestCase {
final Collection<Change> changes = clManager.getDefaultChangeList().getChanges();
final RollbackWorker worker = new RollbackWorker(myProject, true);
final RollbackWorker worker = new RollbackWorker(myProject);
worker.doRollback(changes, false, null, null);
assertVF(subTree.myRootDir, "source");