Search in sources :

Example 41 with ChangeListManager

use of com.intellij.openapi.vcs.changes.ChangeListManager in project intellij-community by JetBrains.

the class SvnRenameTest method testRenameFileRenameDir.

// IDEA-13824
@Test
public void testRenameFileRenameDir() throws Exception {
    final VirtualFile child = prepareDirectoriesForRename();
    final VirtualFile f = child.findChild("a.txt");
    renameFileInCommand(f, "anew.txt");
    renameFileInCommand(child, "newchild");
    verifySorted(runSvn("status"), "A + newchild", "A + newchild" + File.separatorChar + "anew.txt", "D child", "D child" + File.separatorChar + "a.txt", "D child" + File.separatorChar + "grandChild", "D child" + File.separatorChar + "grandChild" + File.separatorChar + "b.txt", "D + newchild" + File.separatorChar + "a.txt");
    final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
    // wait for end of refresh operations initiated from SvnFileSystemListener
    refreshVfs();
    changeListManager.ensureUpToDate(false);
    final List<Change> changes = new ArrayList<>(changeListManager.getDefaultChangeList().getChanges());
    final List<VcsException> list = SvnVcs.getInstance(myProject).getCheckinEnvironment().commit(changes, "test");
    Assert.assertEquals(0, list.size());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsException(com.intellij.openapi.vcs.VcsException) ArrayList(java.util.ArrayList) Change(com.intellij.openapi.vcs.changes.Change) ChangeListManager(com.intellij.openapi.vcs.changes.ChangeListManager) Test(org.junit.Test)

Example 42 with ChangeListManager

use of com.intellij.openapi.vcs.changes.ChangeListManager in project intellij-community by JetBrains.

the class SvnRenameTest method testMovePackageToParent.

// IDEADEV-7697
@Test
public void testMovePackageToParent() throws Exception {
    enableSilentOperation(VcsConfiguration.StandardConfirmation.ADD);
    final VirtualFile child = createDirInCommand(myWorkingCopyDir, "child");
    final VirtualFile grandChild = createDirInCommand(child, "grandChild");
    createFileInCommand(grandChild, "a.txt", "a");
    checkin();
    final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
    moveFileInCommand(grandChild, myWorkingCopyDir);
    // wait for end of refresh operations initiated from SvnFileSystemListener
    refreshVfs();
    changeListManager.ensureUpToDate(false);
    final List<Change> changes = new ArrayList<>(changeListManager.getDefaultChangeList().getChanges());
    Assert.assertEquals(listToString(changes), 2, changes.size());
    sortChanges(changes);
    verifyChange(changes.get(0), "child" + File.separatorChar + "grandChild", "grandChild");
    verifyChange(changes.get(1), "child" + File.separatorChar + "grandChild" + File.separatorChar + "a.txt", "grandChild" + File.separatorChar + "a.txt");
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ArrayList(java.util.ArrayList) Change(com.intellij.openapi.vcs.changes.Change) ChangeListManager(com.intellij.openapi.vcs.changes.ChangeListManager) Test(org.junit.Test)

Example 43 with ChangeListManager

use of com.intellij.openapi.vcs.changes.ChangeListManager in project intellij-community by JetBrains.

the class SvnRenameTest method testRenamePackageWithChildren.

// IDEADEV-15876
@Test
public void testRenamePackageWithChildren() throws Exception {
    final VirtualFile child = prepareDirectoriesForRename();
    renameFileInCommand(child, "childnew");
    final ProcessOutput result = runSvn("status");
    verifySorted(result, "A + childnew", "D child", "D child" + File.separatorChar + "a.txt", "D child" + File.separatorChar + "grandChild", "D child" + File.separatorChar + "grandChild" + File.separatorChar + "b.txt");
    // wait for end of refresh operations initiated from SvnFileSystemListener
    refreshVfs();
    final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
    changeListManager.ensureUpToDate(false);
    List<Change> changes = new ArrayList<>(changeListManager.getDefaultChangeList().getChanges());
    Assert.assertEquals(4, changes.size());
    sortChanges(changes);
    verifyChange(changes.get(0), "child", "childnew");
    verifyChange(changes.get(1), "child" + File.separatorChar + "a.txt", "childnew" + File.separatorChar + "a.txt");
    verifyChange(changes.get(2), "child" + File.separatorChar + "grandChild", "childnew" + File.separatorChar + "grandChild");
    verifyChange(changes.get(3), "child" + File.separatorChar + "grandChild" + File.separatorChar + "b.txt", "childnew" + File.separatorChar + "grandChild" + File.separatorChar + "b.txt");
    VirtualFile oldChild = myWorkingCopyDir.findChild("child");
    Assert.assertEquals(FileStatus.DELETED, changeListManager.getStatus(oldChild));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ProcessOutput(com.intellij.execution.process.ProcessOutput) ArrayList(java.util.ArrayList) Change(com.intellij.openapi.vcs.changes.Change) ChangeListManager(com.intellij.openapi.vcs.changes.ChangeListManager) Test(org.junit.Test)

Example 44 with ChangeListManager

use of com.intellij.openapi.vcs.changes.ChangeListManager in project intellij-community by JetBrains.

the class SvnRenameTest method testRollbackRenameWithUnversioned.

// IDEADEV-19223
@Test
public void testRollbackRenameWithUnversioned() throws Exception {
    enableSilentOperation(VcsConfiguration.StandardConfirmation.ADD);
    final VirtualFile child = createDirInCommand(myWorkingCopyDir, "child");
    createFileInCommand(child, "a.txt", "a");
    checkin();
    disableSilentOperation(VcsConfiguration.StandardConfirmation.ADD);
    final VirtualFile unversioned = createFileInCommand(child, "u.txt", "u");
    final VirtualFile unversionedDir = createDirInCommand(child, "uc");
    createFileInCommand(unversionedDir, "c.txt", "c");
    final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
    changeListManager.ensureUpToDate(false);
    Assert.assertEquals(FileStatus.UNKNOWN, changeListManager.getStatus(unversioned));
    renameFileInCommand(child, "newchild");
    File childPath = new File(myWorkingCopyDir.getPath(), "child");
    File newChildPath = new File(myWorkingCopyDir.getPath(), "newchild");
    Assert.assertTrue(new File(newChildPath, "a.txt").exists());
    Assert.assertTrue(new File(newChildPath, "u.txt").exists());
    Assert.assertFalse(new File(childPath, "u.txt").exists());
    refreshVfs();
    changeListManager.ensureUpToDate(false);
    final List<Change> changes = new ArrayList<>();
    changes.add(ChangeListManager.getInstance(myProject).getChange(myWorkingCopyDir.findChild("newchild").findChild("a.txt")));
    changes.add(ChangeListManager.getInstance(myProject).getChange(myWorkingCopyDir.findChild("newchild")));
    final List<VcsException> exceptions = new ArrayList<>();
    SvnVcs.getInstance(myProject).getRollbackEnvironment().rollbackChanges(changes, exceptions, RollbackProgressListener.EMPTY);
    TimeoutUtil.sleep(300);
    Assert.assertTrue(exceptions.isEmpty());
    final File fileA = new File(childPath, "a.txt");
    Assert.assertTrue(fileA.getAbsolutePath(), fileA.exists());
    final File fileU = new File(childPath, "u.txt");
    Assert.assertTrue(fileU.getAbsolutePath(), fileU.exists());
    final File unversionedDirFile = new File(childPath, "uc");
    Assert.assertTrue(unversionedDirFile.exists());
    Assert.assertTrue(new File(unversionedDirFile, "c.txt").exists());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsException(com.intellij.openapi.vcs.VcsException) ArrayList(java.util.ArrayList) Change(com.intellij.openapi.vcs.changes.Change) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) ChangeListManager(com.intellij.openapi.vcs.changes.ChangeListManager) Test(org.junit.Test)

Example 45 with ChangeListManager

use of com.intellij.openapi.vcs.changes.ChangeListManager in project intellij-community by JetBrains.

the class SvnConcurrentChangeListManagerTest method testSwitchedFileAndFolder.

@Test
public void testSwitchedFileAndFolder() throws Exception {
    final String branchUrl = prepareBranchesStructure();
    final SubTree tree = new SubTree(myWorkingCopyDir);
    runInAndVerifyIgnoreOutput("switch", branchUrl + "/root/source/s1.txt", tree.myS1File.getPath());
    runInAndVerifyIgnoreOutput("switch", branchUrl + "/root/target", tree.myTargetDir.getPath());
    final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
    VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
    changeListManager.ensureUpToDate(false);
    final Runnable check = () -> {
        Assert.assertEquals(FileStatus.SWITCHED, changeListManager.getStatus(tree.myS1File));
        Assert.assertEquals(FileStatus.NOT_CHANGED, changeListManager.getStatus(tree.myS2File));
        Assert.assertEquals(FileStatus.NOT_CHANGED, changeListManager.getStatus(tree.mySourceDir));
        Assert.assertEquals(FileStatus.SWITCHED, changeListManager.getStatus(tree.myTargetDir));
        Assert.assertEquals(FileStatus.SWITCHED, changeListManager.getStatus(tree.myTargetFiles.get(1)));
    };
    myScheme.doTest(check);
    changeListManager.ensureUpToDate(false);
    check.run();
    VcsTestUtil.editFileInCommand(myProject, tree.myS1File, "1234543534543 3543 ");
    VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
    changeListManager.ensureUpToDate(false);
    final Runnable check2 = () -> {
        Assert.assertEquals(FileStatus.MODIFIED, changeListManager.getStatus(tree.myS1File));
        Assert.assertEquals(FileStatus.NOT_CHANGED, changeListManager.getStatus(tree.myS2File));
        Assert.assertEquals(FileStatus.NOT_CHANGED, changeListManager.getStatus(tree.mySourceDir));
        Assert.assertEquals(FileStatus.SWITCHED, changeListManager.getStatus(tree.myTargetDir));
        Assert.assertEquals(FileStatus.SWITCHED, changeListManager.getStatus(tree.myTargetFiles.get(1)));
    };
    myScheme.doTest(check2);
    changeListManager.ensureUpToDate(false);
    check2.run();
}
Also used : ChangeListManager(com.intellij.openapi.vcs.changes.ChangeListManager) Test(org.junit.Test)

Aggregations

ChangeListManager (com.intellij.openapi.vcs.changes.ChangeListManager)77 VirtualFile (com.intellij.openapi.vfs.VirtualFile)65 Test (org.junit.Test)57 Change (com.intellij.openapi.vcs.changes.Change)42 File (java.io.File)28 LocalChangeList (com.intellij.openapi.vcs.changes.LocalChangeList)24 ConflictVersion (org.jetbrains.idea.svn.conflict.ConflictVersion)23 TreeConflictDescription (org.jetbrains.idea.svn.conflict.TreeConflictDescription)23 ArrayList (java.util.ArrayList)11 VcsException (com.intellij.openapi.vcs.VcsException)6 NotNull (org.jetbrains.annotations.NotNull)4 ContentRevision (com.intellij.openapi.vcs.changes.ContentRevision)3 ProcessOutput (com.intellij.execution.process.ProcessOutput)2 ChangeList (com.intellij.openapi.vcs.changes.ChangeList)2 Nullable (org.jetbrains.annotations.Nullable)2 AccessToken (com.intellij.openapi.application.AccessToken)1 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)1 FileNodeDescriptor (com.intellij.openapi.fileChooser.ex.FileNodeDescriptor)1 FileSystemTreeImpl (com.intellij.openapi.fileChooser.ex.FileSystemTreeImpl)1 Project (com.intellij.openapi.project.Project)1