Search in sources :

Example 51 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 52 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 53 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)

Example 54 with VcsException

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

the class DiffContentRevision method getContentAsBytes.

@NotNull
@Override
public byte[] getContentAsBytes() throws VcsException {
    if (myContents == null) {
        BufferExposingByteArrayOutputStream bos = new BufferExposingByteArrayOutputStream(2048);
        try {
            myRepository.getFile(myPath, -1, null, bos);
            myRepository.closeSession();
        } catch (SVNException e) {
            throw new VcsException(e);
        }
        myContents = bos.toByteArray();
    }
    return myContents;
}
Also used : BufferExposingByteArrayOutputStream(com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream) VcsException(com.intellij.openapi.vcs.VcsException) SVNException(org.tmatesoft.svn.core.SVNException) NotNull(org.jetbrains.annotations.NotNull)

Example 55 with VcsException

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

the class ElementWithBranchComparer method run.

public void run() {
    new Task.Modal(myProject, getTitle(), true) {

        @Override
        public void run(@NotNull ProgressIndicator indicator) {
            try {
                beforeCompare();
                myElementUrl = resolveElementUrl();
                if (myElementUrl == null) {
                    reportNotFound();
                } else {
                    compare();
                }
            } catch (SVNCancelException ex) {
                ElementWithBranchComparer.this.onCancel();
            } catch (SVNException ex) {
                reportException(new SvnBindException(ex));
            } catch (SvnBindException ex) {
                reportException(ex);
            } catch (VcsException ex) {
                reportGeneralException(ex);
            }
        }
    }.queue();
    showResult();
}
Also used : Task(com.intellij.openapi.progress.Task) SvnBindException(org.jetbrains.idea.svn.commandLine.SvnBindException) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) SVNCancelException(org.tmatesoft.svn.core.SVNCancelException) VcsException(com.intellij.openapi.vcs.VcsException) 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