Search in sources :

Example 26 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 27 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)

Example 28 with VcsException

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

the class HgUpdateTest method updateShouldMergeButNotCommitWithConflicts.

@Test
public void updateShouldMergeButNotCommitWithConflicts() throws Exception {
    changeFile_A_AndCommitInRemoteRepository();
    VirtualFile commonFile = projectRepoVirtualFile.findChild("com").findChild("a.txt");
    assertNotNull(commonFile);
    VcsTestUtil.editFileInCommand(myProject, commonFile, "conflicting content");
    runHg(projectRepo, "commit", "-m", "adding conflicting history to local repository");
    PreUpdateInformation preUpdateInformation = new PreUpdateInformation().getPreUpdateInformation();
    HgRevisionNumber incomingHead = preUpdateInformation.getIncomingHead();
    HgRevisionNumber headBeforeUpdate = preUpdateInformation.getHeadBeforeUpdate();
    List<VcsException> warnings = updateThroughPlugin();
    assertFalse(warnings.isEmpty());
    assertTrue(warnings.get(warnings.size() - 1).getMessage().contains("conflicts"));
    assertTrue(warnings.get(warnings.size() - 1).getMessage().contains("commit"));
    List<HgRevisionNumber> parents = new HgWorkingCopyRevisionsCommand(myProject).parents(projectRepoVirtualFile);
    assertEquals(parents.size(), 2);
    assertTrue(parents.contains(incomingHead));
    assertTrue(parents.contains(headBeforeUpdate));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) HgRevisionNumber(org.zmlx.hg4idea.HgRevisionNumber) VcsException(com.intellij.openapi.vcs.VcsException) Test(org.testng.annotations.Test)

Example 29 with VcsException

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

the class HgUpdateTest method localChangesShouldBeAllowedWithFastForwardUpdate.

@Test
public void localChangesShouldBeAllowedWithFastForwardUpdate() throws Exception {
    createFileInCommand(projectRepoVirtualFile.findChild("com"), "b.txt", "other file");
    runHg(projectRepo, "commit", "-m", "adding second file");
    runHg(projectRepo, "push");
    runHg(remoteRepo, "update");
    changeFile_A_AndCommitInRemoteRepository();
    fillFile(projectRepo, new String[] { "com", "b.txt" }, "local change");
    createFileInCommand(projectRepoVirtualFile.findChild("com"), "c.txt", "other file");
    assertIsChanged(HgFileStatusEnum.MODIFIED, "com", "b.txt");
    assertIsChanged(HgFileStatusEnum.ADDED, "com", "c.txt");
    PreUpdateInformation information = new PreUpdateInformation().getPreUpdateInformation();
    HgRevisionNumber incomingHead = information.getIncomingHead();
    List<VcsException> nonFatalWarnings = updateThroughPlugin();
    assertTrue(nonFatalWarnings.isEmpty());
    HgRevisionNumber parentAfterUpdate = new HgParentsCommand(myProject).executeInCurrentThread(projectRepoVirtualFile).get(0);
    assertEquals(incomingHead, parentAfterUpdate);
    assertIsChanged(HgFileStatusEnum.MODIFIED, "com", "b.txt");
    assertIsChanged(HgFileStatusEnum.ADDED, "com", "c.txt");
}
Also used : HgRevisionNumber(org.zmlx.hg4idea.HgRevisionNumber) VcsException(com.intellij.openapi.vcs.VcsException) Test(org.testng.annotations.Test)

Example 30 with VcsException

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

the class SvnKitDeleteClient method delete.

@Override
public void delete(@NotNull File path, boolean force, boolean dryRun, @Nullable ProgressTracker handler) throws VcsException {
    SVNWCClient client = myVcs.getSvnKitManager().createWCClient();
    client.setEventHandler(toEventHandler(handler));
    try {
        client.doDelete(path, force, dryRun);
    } catch (SVNException e) {
        throw new VcsException(e);
    }
}
Also used : VcsException(com.intellij.openapi.vcs.VcsException) SVNWCClient(org.tmatesoft.svn.core.wc.SVNWCClient) SVNException(org.tmatesoft.svn.core.SVNException)

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