Search in sources :

Example 6 with VcsException

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

the class SvnCheckoutProvider method doExport.

public static void doExport(final Project project, final File target, final SVNURL url, final Depth depth, final boolean ignoreExternals, final boolean force, final String eolStyle) {
    try {
        final VcsException[] exception = new VcsException[1];
        final SvnVcs vcs = SvnVcs.getInstance(project);
        ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
            ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
            ProgressTracker handler = new CheckoutEventHandler(vcs, true, progressIndicator);
            try {
                progressIndicator.setText(message("progress.text.export", target.getAbsolutePath()));
                SvnTarget from = SvnTarget.fromURL(url);
                ExportClient client = vcs.getFactoryFromSettings().createExportClient();
                client.export(from, target, SVNRevision.HEAD, depth, eolStyle, force, ignoreExternals, handler);
            } catch (VcsException e) {
                exception[0] = e;
            }
        }, message("message.title.export"), true, project);
        if (exception[0] != null) {
            throw exception[0];
        }
    } catch (VcsException e1) {
        showErrorDialog(message("message.text.cannot.export", e1.getMessage()), message("message.title.export"));
    }
}
Also used : ProgressTracker(org.jetbrains.idea.svn.api.ProgressTracker) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) VcsException(com.intellij.openapi.vcs.VcsException) SvnTarget(org.tmatesoft.svn.core.wc2.SvnTarget) SvnVcs(org.jetbrains.idea.svn.SvnVcs)

Example 7 with VcsException

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

the class SvnCheckoutProvider method doImport.

public static void doImport(final Project project, final File target, final SVNURL url, final Depth depth, final boolean includeIgnored, final String message) {
    final Ref<String> errorMessage = new Ref<>();
    final SvnVcs vcs = SvnVcs.getInstance(project);
    final String targetPath = FileUtil.toSystemIndependentName(target.getAbsolutePath());
    ExclusiveBackgroundVcsAction.run(project, () -> ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
        final FileIndexFacade facade = PeriodicalTasksCloser.getInstance().safeGetService(project, FileIndexFacade.class);
        ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
        try {
            progressIndicator.setText(message("progress.text.import", target.getAbsolutePath()));
            final VirtualFile targetVf = SvnUtil.getVirtualFile(targetPath);
            if (targetVf == null) {
                errorMessage.set("Can not find file: " + targetPath);
            } else {
                final boolean isInContent = getApplication().runReadAction((Computable<Boolean>) () -> facade.isInContent(targetVf));
                CommitEventHandler handler = new IdeaCommitHandler(progressIndicator);
                boolean useFileFilter = !project.isDefault() && isInContent;
                ISVNCommitHandler commitHandler = useFileFilter ? new MyFilter(LocalFileSystem.getInstance(), new SvnExcludingIgnoredOperation.Filter(project)) : null;
                long revision = vcs.getFactoryFromSettings().createImportClient().doImport(target, url, depth, message, includeIgnored, handler, commitHandler);
                if (revision > 0) {
                    StatusBar.Info.set(message("status.text.comitted.revision", revision), project);
                }
            }
        } catch (VcsException e) {
            errorMessage.set(e.getMessage());
        }
    }, message("message.title.import"), true, project));
    if (!errorMessage.isNull()) {
        showErrorDialog(message("message.text.cannot.import", errorMessage.get()), message("message.title.import"));
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) IdeaCommitHandler(org.jetbrains.idea.svn.checkin.IdeaCommitHandler) ISVNCommitHandler(org.tmatesoft.svn.core.wc.ISVNCommitHandler) CommitEventHandler(org.jetbrains.idea.svn.checkin.CommitEventHandler) SvnVcs(org.jetbrains.idea.svn.SvnVcs) Ref(com.intellij.openapi.util.Ref) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) SvnExcludingIgnoredOperation(org.jetbrains.idea.svn.actions.SvnExcludingIgnoredOperation) VcsException(com.intellij.openapi.vcs.VcsException) Computable(com.intellij.openapi.util.Computable) FileIndexFacade(com.intellij.openapi.roots.FileIndexFacade)

Example 8 with VcsException

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

the class ShareWholeProject method actionPerformed.

public void actionPerformed(AnActionEvent e) {
    final MyChecker checker = new MyChecker();
    checker.execute(e);
    if (!checker.isEnabled())
        return;
    final Project project = checker.getProject();
    final VirtualFile baseDir = project.getBaseDir();
    if (baseDir == null)
        return;
    boolean success = false;
    boolean excThrown = false;
    try {
        success = ShareProjectAction.share(project, baseDir);
    } catch (VcsException exc) {
        AbstractVcsHelper.getInstance(project).showError(exc, "Failed to Share Project");
        excThrown = true;
    } finally {
        // if success = false -> either action was cancelled or exception was thrown, so also check for exception
        if (success || excThrown) {
            baseDir.refresh(true, true, () -> ApplicationManager.getApplication().invokeLater(() -> {
                VcsDirtyScopeManager.getInstance(project).dirDirtyRecursively(project.getBaseDir());
                if (checker.isHadNoMappings() && SvnUtil.seemsLikeVersionedDir(baseDir)) {
                    final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(project);
                    vcsManager.setDirectoryMappings(Arrays.asList(new VcsDirectoryMapping("", SvnVcs.VCS_NAME)));
                }
            }, ModalityState.NON_MODAL, project.getDisposed()));
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) VcsDirectoryMapping(com.intellij.openapi.vcs.VcsDirectoryMapping) VcsException(com.intellij.openapi.vcs.VcsException) ProjectLevelVcsManager(com.intellij.openapi.vcs.ProjectLevelVcsManager)

Example 9 with VcsException

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

the class SvnMergeProvider method conflictResolvedForFile.

public void conflictResolvedForFile(@NotNull VirtualFile file) {
    // TODO: Add possibility to resolve content conflicts separately from property conflicts.
    SvnVcs vcs = SvnVcs.getInstance(myProject);
    File path = virtualToIoFile(file);
    try {
        // TODO: Probably false should be passed to "resolveTree", but previous logic used true implicitly
        vcs.getFactory(path).createConflictClient().resolve(path, Depth.EMPTY, false, true, true);
    } catch (VcsException e) {
        LOG.warn(e);
    }
    // the .mine/.r## files have been deleted
    final VirtualFile parent = file.getParent();
    if (parent != null) {
        parent.refresh(true, false);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsException(com.intellij.openapi.vcs.VcsException) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile) File(java.io.File) SvnVcs(org.jetbrains.idea.svn.SvnVcs)

Example 10 with VcsException

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

the class SvnMergeProvider method getBaseRevisionContents.

private ByteArrayOutputStream getBaseRevisionContents(@NotNull SvnVcs vcs, @NotNull VirtualFile file) {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    try {
        byte[] contents = SvnUtil.getFileContents(vcs, SvnTarget.fromFile(virtualToIoFile(file)), SVNRevision.BASE, SVNRevision.UNDEFINED);
        bos.write(contents);
    } catch (VcsException | IOException e) {
        LOG.warn(e);
    }
    return bos;
}
Also used : VcsException(com.intellij.openapi.vcs.VcsException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException)

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