Search in sources :

Example 71 with VirtualFile

use of com.intellij.openapi.vfs.VirtualFile in project intellij-community by JetBrains.

the class HgCopyTest method testCopyModifiedFile.

@Test
public void testCopyModifiedFile() throws Exception {
    VirtualFile file = createFileInCommand("a.txt", "new file content");
    runHgOnProjectRepo("commit", "-m", "added file");
    VcsTestUtil.editFileInCommand(myProject, file, "newer content");
    verify(runHgOnProjectRepo("status"), HgTestOutputParser.modified("a.txt"));
    copyFileInCommand(file, "b.txt");
    verify(runHgOnProjectRepo("status"), HgTestOutputParser.modified("a.txt"), HgTestOutputParser.added("b.txt"));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Test(org.testng.annotations.Test)

Example 72 with VirtualFile

use of com.intellij.openapi.vfs.VirtualFile in project intellij-community by JetBrains.

the class HgCopyTest method testCopyCopiedFile.

@Test
public void testCopyCopiedFile() throws Exception {
    VirtualFile file = createFileInCommand("a.txt", "new file content");
    runHgOnProjectRepo("commit", "-m", "added file");
    copyFileInCommand(file, "b.txt");
    copyFileInCommand(file, "c.txt");
    verify(runHgOnProjectRepo("status"), HgTestOutputParser.added("b.txt"), HgTestOutputParser.added("c.txt"));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Test(org.testng.annotations.Test)

Example 73 with VirtualFile

use of com.intellij.openapi.vfs.VirtualFile in project intellij-community by JetBrains.

the class HgDeleteTest method testJustDeletedAndThenAddedFileShouldNotBePromptedForRemoval.

/**
   * A file is also considered to be newly added, if it has a history, but the last action was removal of that file.
   * 1. Create a file, add it to the repository and commit.
   * 2. Delete the file and commit it.
   * 3. Create the file again and add it to the repository.
   * 4. Delete the file.
   * 5. File shouldn't be prompted for removal from repository.
   */
@Test
public void testJustDeletedAndThenAddedFileShouldNotBePromptedForRemoval() throws Exception {
    VirtualFile vf = createFileInCommand("a.txt", null);
    myChangeListManager.commitFiles(vf);
    deleteFileInCommand(vf);
    myChangeListManager.commitFiles(vf);
    showConfirmation(VcsConfiguration.StandardConfirmation.REMOVE);
    vf = createFileInCommand("a.txt", null);
    final HgMockVcsHelper helper = registerMockVcsHelper();
    helper.addListener(new VcsHelperListener() {

        @Override
        public void dialogInvoked() {
            fail("No dialog should be invoked, because newly added file should be silently removed from the repository");
        }
    });
    VcsTestUtil.deleteFileInCommand(myProject, vf);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Test(org.testng.annotations.Test)

Example 74 with VirtualFile

use of com.intellij.openapi.vfs.VirtualFile in project intellij-community by JetBrains.

the class HgDeleteTest method testDeleteModifiedFile.

@Test
public void testDeleteModifiedFile() throws Exception {
    VirtualFile file = createFileInCommand("a.txt", "new file content");
    runHgOnProjectRepo("commit", "-m", "added file");
    VcsTestUtil.editFileInCommand(myProject, file, "even newer content");
    verify(runHgOnProjectRepo("status"), HgTestOutputParser.modified("a.txt"));
    deleteFileInCommand(file);
    verify(runHgOnProjectRepo("status"), HgTestOutputParser.removed("a.txt"));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Test(org.testng.annotations.Test)

Example 75 with VirtualFile

use of com.intellij.openapi.vfs.VirtualFile in project intellij-community by JetBrains.

the class HgDeleteTest method testNewlyAddedFileShouldNotBePromptedForRemoval.

/**
   * When deleting a file which was newly added to repository, this file shouldn't be prompted for removal from the repository.
   * 1. Create a file and add it to the repository.
   * 2. Remove the file from disk.
   * 3. File shouldn't be prompted for removal from repository.
   */
@Test
public void testNewlyAddedFileShouldNotBePromptedForRemoval() throws Exception {
    showConfirmation(VcsConfiguration.StandardConfirmation.REMOVE);
    final VirtualFile vf = createFileInCommand("a.txt", null);
    final HgMockVcsHelper helper = registerMockVcsHelper();
    helper.addListener(new VcsHelperListener() {

        @Override
        public void dialogInvoked() {
            fail("No dialog should be invoked, because newly added file should be silently removed from the repository");
        }
    });
    deleteFileInCommand(vf);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Test(org.testng.annotations.Test)

Aggregations

VirtualFile (com.intellij.openapi.vfs.VirtualFile)5465 File (java.io.File)762 Project (com.intellij.openapi.project.Project)720 Nullable (org.jetbrains.annotations.Nullable)720 NotNull (org.jetbrains.annotations.NotNull)703 PsiFile (com.intellij.psi.PsiFile)571 Module (com.intellij.openapi.module.Module)501 IOException (java.io.IOException)327 ArrayList (java.util.ArrayList)260 Document (com.intellij.openapi.editor.Document)244 PsiElement (com.intellij.psi.PsiElement)209 Test (org.junit.Test)196 ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)124 PsiDirectory (com.intellij.psi.PsiDirectory)124 XmlFile (com.intellij.psi.xml.XmlFile)124 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)116 Editor (com.intellij.openapi.editor.Editor)115 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)101 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)91 List (java.util.List)90