Search in sources :

Example 46 with VcsException

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

the class SvnProtocolsTest method testCommitImpl.

private File testCommitImpl(File wc1) throws IOException {
    Assert.assertTrue(wc1.isDirectory());
    final File file = FileUtil.createTempFile(wc1, "file", ".txt");
    final VirtualFile vf = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file);
    Assert.assertNotNull(vf);
    final ArrayList<VirtualFile> files = new ArrayList<>();
    files.add(vf);
    final List<VcsException> exceptions = myVcs.getCheckinEnvironment().scheduleUnversionedFilesForAddition(files);
    Assert.assertTrue(exceptions.isEmpty());
    final Change change = new Change(null, new CurrentContentRevision(VcsUtil.getFilePath(vf)));
    final List<VcsException> commit = myVcs.getCheckinEnvironment().commit(Collections.singletonList(change), "commit");
    Assert.assertTrue(commit.isEmpty());
    return file;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) CurrentContentRevision(com.intellij.openapi.vcs.changes.CurrentContentRevision) 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)

Example 47 with VcsException

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

the class SvnCommitTest method checkinFiles.

private HashSet<String> checkinFiles(VirtualFile... files) {
    final List<Change> changes = new ArrayList<>();
    for (VirtualFile file : files) {
        final Change change = myChangeListManager.getChange(file);
        Assert.assertNotNull(change);
        changes.add(change);
    }
    final HashSet<String> feedback = new HashSet<>();
    final List<VcsException> exceptions = myVcs.getCheckinEnvironment().commit(changes, "test comment list", o -> null, feedback);
    if (exceptions != null && !exceptions.isEmpty()) {
        exceptions.get(0).printStackTrace();
    }
    Assert.assertTrue(exceptions == null || exceptions.isEmpty());
    myDirtyScopeManager.markEverythingDirty();
    myChangeListManager.ensureUpToDate(false);
    for (VirtualFile file : files) {
        final Change changeA = myChangeListManager.getChange(file);
        Assert.assertNull(changeA);
    }
    return feedback;
}
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) HashSet(java.util.HashSet)

Example 48 with VcsException

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

the class SvnRenameTest method testRenameFileRenameDir.

// IDEA-13824
@Test
public void testRenameFileRenameDir() throws Exception {
    //todo debug
    setNativeAcceleration(true);
    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);
    insideInitializedChangeListManager(changeListManager, () -> {
        // 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 49 with VcsException

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

the class SvnRenameTest method testRollbackRenameDir.

// todo - undo; undo after commit
// IDEADEV-9755
@Test
public void testRollbackRenameDir() throws Exception {
    final VirtualFile child = prepareDirectoriesForRename();
    renameFileInCommand(child, "newchild");
    final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
    insideInitializedChangeListManager(changeListManager, () -> {
        changeListManager.ensureUpToDate(false);
        final Change change = changeListManager.getChange(myWorkingCopyDir.findChild("newchild"));
        Assert.assertNotNull(change);
        final List<VcsException> exceptions = new ArrayList<>();
        SvnVcs.getInstance(myProject).getRollbackEnvironment().rollbackChanges(Collections.singletonList(change), exceptions, RollbackProgressListener.EMPTY);
        Assert.assertTrue(exceptions.isEmpty());
        Assert.assertFalse(new File(myWorkingCopyDir.getPath(), "newchild").exists());
        Assert.assertTrue(new File(myWorkingCopyDir.getPath(), "child").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 50 with VcsException

use of com.intellij.openapi.vcs.VcsException 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);
    insideInitializedChangeListManager(changeListManager, () -> {
        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)

Aggregations

VcsException (com.intellij.openapi.vcs.VcsException)200 VirtualFile (com.intellij.openapi.vfs.VirtualFile)89 File (java.io.File)48 NotNull (org.jetbrains.annotations.NotNull)42 FilePath (com.intellij.openapi.vcs.FilePath)35 Change (com.intellij.openapi.vcs.changes.Change)33 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)26 ArrayList (java.util.ArrayList)24 Nullable (org.jetbrains.annotations.Nullable)23 IOException (java.io.IOException)20 SVNException (org.tmatesoft.svn.core.SVNException)19 Project (com.intellij.openapi.project.Project)17 Ref (com.intellij.openapi.util.Ref)16 Test (org.junit.Test)14 VfsUtilCore.virtualToIoFile (com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)13 GitRepository (git4idea.repo.GitRepository)12 Task (com.intellij.openapi.progress.Task)11 List (java.util.List)11 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)10 ContentRevision (com.intellij.openapi.vcs.changes.ContentRevision)10