use of com.intellij.openapi.vcs.changes.ui.RollbackWorker in project intellij-community by JetBrains.
the class ShelveChangesManager method shelveChanges.
public ShelvedChangeList shelveChanges(final Collection<Change> changes, final String commitMessage, final boolean rollback, boolean markToBeDeleted) throws IOException, VcsException {
final ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
if (progressIndicator != null) {
progressIndicator.setText(VcsBundle.message("shelve.changes.progress.title"));
}
File schemePatchDir = generateUniqueSchemePatchDir(commitMessage, true);
final List<Change> textChanges = new ArrayList<>();
final List<ShelvedBinaryFile> binaryFiles = new ArrayList<>();
for (Change change : changes) {
if (ChangesUtil.getFilePath(change).isDirectory()) {
continue;
}
if (change.getBeforeRevision() instanceof BinaryContentRevision || change.getAfterRevision() instanceof BinaryContentRevision) {
binaryFiles.add(shelveBinaryFile(schemePatchDir, change));
} else {
textChanges.add(change);
}
}
final ShelvedChangeList changeList;
try {
File patchFile = getPatchFileInConfigDir(schemePatchDir);
ProgressManager.checkCanceled();
final List<FilePatch> patches = IdeaTextPatchBuilder.buildPatch(myProject, textChanges, myProject.getBaseDir().getPresentableUrl(), false);
ProgressManager.checkCanceled();
CommitContext commitContext = new CommitContext();
baseRevisionsOfDvcsIntoContext(textChanges, commitContext);
ShelfFileProcessorUtil.savePatchFile(myProject, patchFile, patches, null, commitContext);
changeList = new ShelvedChangeList(patchFile.toString(), commitMessage.replace('\n', ' '), binaryFiles);
changeList.markToDelete(markToBeDeleted);
changeList.setName(schemePatchDir.getName());
ProgressManager.checkCanceled();
mySchemeManager.addNewScheme(changeList, false);
if (rollback) {
final String operationName = UIUtil.removeMnemonic(RollbackChangesDialog.operationNameByChanges(myProject, changes));
boolean modalContext = ApplicationManager.getApplication().isDispatchThread() && LaterInvocator.isInModalContext();
if (progressIndicator != null) {
progressIndicator.startNonCancelableSection();
}
new RollbackWorker(myProject, operationName, modalContext).doRollback(changes, true, null, VcsBundle.message("shelve.changes.action"));
}
} finally {
notifyStateChanged();
}
return changeList;
}
use of com.intellij.openapi.vcs.changes.ui.RollbackWorker in project intellij-community by JetBrains.
the class SvnChangesCorrectlyRefreshedTest method testMoveFileAndAfterRevert.
@Test
public void testMoveFileAndAfterRevert() throws Throwable {
final SubTree subTree = new SubTree(myWorkingCopyDir);
checkin();
moveFileInCommand(subTree.myS1File, subTree.myTargetDir);
assertVF(subTree.myTargetDir, "s1.txt");
sleep(300);
VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
clManager.ensureUpToDate(false);
DuringChangeListManagerUpdateTestScheme.checkFilesAreInList(new VirtualFile[] { subTree.myS1File }, clManager.getDefaultListName(), clManager);
final Collection<Change> changes = clManager.getDefaultChangeList().getChanges();
final RollbackWorker worker = new RollbackWorker(myProject);
worker.doRollback(changes, false, null, null);
assertVF(subTree.mySourceDir, "s1.txt");
clManager.ensureUpToDate(false);
DuringChangeListManagerUpdateTestScheme.checkFilesAreInList(VirtualFile.EMPTY_ARRAY, clManager.getDefaultListName(), clManager);
}
use of com.intellij.openapi.vcs.changes.ui.RollbackWorker in project intellij-community by JetBrains.
the class SvnChangesCorrectlyRefreshedTest method testMoveDirEditFileAndAfterRevert.
@Test
public void testMoveDirEditFileAndAfterRevert() throws Throwable {
final SubTree subTree = new SubTree(myWorkingCopyDir);
checkin();
moveFileInCommand(subTree.mySourceDir, subTree.myTargetDir);
Assert.assertTrue(subTree.mySourceDir.getPath().endsWith("/target/source"));
assertVF(subTree.myTargetDir, "source");
VcsTestUtil.editFileInCommand(myProject, subTree.myS1File, "new");
final CharSequence text1 = LoadTextUtil.loadText(subTree.myS1File);
Assert.assertEquals("new", text1.toString());
sleep(300);
VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
clManager.ensureUpToDate(false);
DuringChangeListManagerUpdateTestScheme.checkFilesAreInList(new VirtualFile[] { subTree.mySourceDir, subTree.myS1File, subTree.myS2File }, clManager.getDefaultListName(), clManager);
final Collection<Change> changes = clManager.getDefaultChangeList().getChanges();
final RollbackWorker worker = new RollbackWorker(myProject);
worker.doRollback(changes, false, null, null);
subTree.mySourceDir = assertVF(subTree.myRootDir, "source");
Assert.assertTrue(subTree.mySourceDir.getPath().endsWith("/root/source"));
subTree.myS1File = assertVF(subTree.mySourceDir, "s1.txt");
subTree.myS2File = assertVF(subTree.mySourceDir, "s2.txt");
final CharSequence text = LoadTextUtil.loadText(subTree.myS1File);
Assert.assertEquals(SubTree.ourS1Contents, text.toString());
clManager.ensureUpToDate(false);
DuringChangeListManagerUpdateTestScheme.checkFilesAreInList(VirtualFile.EMPTY_ARRAY, clManager.getDefaultListName(), clManager);
}
use of com.intellij.openapi.vcs.changes.ui.RollbackWorker in project intellij-community by JetBrains.
the class SvnChangesCorrectlyRefreshedTest method testRenameFileAndAfterRevert.
@Test
public void testRenameFileAndAfterRevert() throws Throwable {
final SubTree subTree = new SubTree(myWorkingCopyDir);
checkin();
final String newName = "newName";
renameFileInCommand(subTree.myS1File, newName);
assertVF(subTree.mySourceDir, newName);
sleep(300);
VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
clManager.ensureUpToDate(false);
DuringChangeListManagerUpdateTestScheme.checkFilesAreInList(new VirtualFile[] { subTree.myS1File }, clManager.getDefaultListName(), clManager);
final Collection<Change> changes = clManager.getDefaultChangeList().getChanges();
final RollbackWorker worker = new RollbackWorker(myProject);
worker.doRollback(changes, false, null, null);
assertVF(subTree.mySourceDir, "s1.txt");
clManager.ensureUpToDate(false);
DuringChangeListManagerUpdateTestScheme.checkFilesAreInList(VirtualFile.EMPTY_ARRAY, clManager.getDefaultListName(), clManager);
}
use of com.intellij.openapi.vcs.changes.ui.RollbackWorker in project intellij-community by JetBrains.
the class SvnChangesCorrectlyRefreshedNativeTest method testMoveFileAndAfterRevert.
@Test
public void testMoveFileAndAfterRevert() throws Throwable {
final SubTree subTree = new SubTree(myWorkingCopyDir);
checkin();
moveFileInCommand(subTree.myS1File, subTree.myTargetDir);
assertVF(subTree.myTargetDir, "s1.txt");
sleep(300);
VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
clManager.ensureUpToDate(false);
DuringChangeListManagerUpdateTestScheme.checkFilesAreInList(new VirtualFile[] { subTree.myS1File }, clManager.getDefaultListName(), clManager);
final Collection<Change> changes = clManager.getDefaultChangeList().getChanges();
final RollbackWorker worker = new RollbackWorker(myProject);
worker.doRollback(changes, false, null, null);
assertVF(subTree.mySourceDir, "s1.txt");
clManager.ensureUpToDate(false);
DuringChangeListManagerUpdateTestScheme.checkFilesAreInList(VirtualFile.EMPTY_ARRAY, clManager.getDefaultListName(), clManager);
}
Aggregations