Search in sources :

Example 46 with SVNException

use of org.tmatesoft.svn.core.SVNException in project intellij-community by JetBrains.

the class SvnUtil method getWcCopyRootIf17.

@Nullable
public static File getWcCopyRootIf17(final File file, @Nullable final File upperBound) {
    File current = getParentWithDb(file);
    if (current == null)
        return null;
    while (current != null) {
        try {
            final SvnWcGeneration svnWcGeneration = SvnOperationFactory.detectWcGeneration(current, false);
            if (SvnWcGeneration.V17.equals(svnWcGeneration))
                return current;
            if (SvnWcGeneration.V16.equals(svnWcGeneration))
                return null;
            if (upperBound != null && FileUtil.filesEqual(upperBound, current))
                return null;
            current = current.getParentFile();
        } catch (SVNException e) {
            return null;
        }
    }
    return null;
}
Also used : SvnWcGeneration(org.tmatesoft.svn.core.internal.wc2.SvnWcGeneration) SVNException(org.tmatesoft.svn.core.SVNException) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile) File(java.io.File) Nullable(org.jetbrains.annotations.Nullable)

Example 47 with SVNException

use of org.tmatesoft.svn.core.SVNException in project intellij-community by JetBrains.

the class SvnKitAddClient method add.

/**
   * TODO: Implement correct support for includeIgnored parameter. Also check that correct depth will be used for all cases (when another
   * TODO: overload of doAdd() is used) as, for instance, SVNDepth.recurseFromDepth(EMPTY) = false, SVNDepth.fromRecursive(false) = FILES.
   */
@Override
public void add(@NotNull File file, @Nullable Depth depth, boolean makeParents, boolean includeIgnored, boolean force, @Nullable ProgressTracker handler) throws VcsException {
    try {
        SVNWCClient client = myVcs.getSvnKitManager().createWCClient();
        client.setEventHandler(toEventHandler(handler));
        client.doAdd(file, force, // directory should already be created
        false, // not used but will be passed as makeParents value
        makeParents, Depth.isRecursive(depth));
    } 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 48 with SVNException

use of org.tmatesoft.svn.core.SVNException in project intellij-community by JetBrains.

the class SvnAnnotationProvider method annotate.

private FileAnnotation annotate(final VirtualFile file, final VcsFileRevision revision, final VcsRevisionNumber lastChangedRevision, final boolean loadExternally) throws VcsException {
    if (file.isDirectory()) {
        throw new VcsException(SvnBundle.message("exception.text.cannot.annotate.directory"));
    }
    final FileAnnotation[] annotation = new FileAnnotation[1];
    final VcsException[] exception = new VcsException[1];
    Runnable command = () -> {
        final ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
        final File ioFile = virtualToIoFile(file).getAbsoluteFile();
        Info info = null;
        try {
            final String contents;
            if (loadExternally) {
                byte[] data = SvnUtil.getFileContents(myVcs, SvnTarget.fromFile(ioFile), SVNRevision.BASE, SVNRevision.UNDEFINED);
                contents = LoadTextUtil.getTextByBinaryPresentation(data, file, false, false).toString();
            } else {
                final byte[] bytes = VcsHistoryUtil.loadRevisionContent(revision);
                contents = LoadTextUtil.getTextByBinaryPresentation(bytes, file, false, false).toString();
            }
            final SvnFileAnnotation result = new SvnFileAnnotation(myVcs, file, contents, lastChangedRevision);
            info = myVcs.getInfo(ioFile);
            if (info == null) {
                exception[0] = new VcsException(new SVNException(SVNErrorMessage.create(SVNErrorCode.UNKNOWN, "File ''{0}'' is not under version control", ioFile)));
                return;
            }
            final String url = info.getURL() == null ? null : info.getURL().toString();
            SVNRevision endRevision = ((SvnFileRevision) revision).getRevision();
            if (SVNRevision.WORKING.equals(endRevision)) {
                endRevision = info.getRevision();
            }
            if (progress != null) {
                progress.setText(SvnBundle.message("progress.text.computing.annotation", file.getName()));
            }
            // ignore mime type=true : IDEA-19562
            final AnnotationConsumer annotateHandler = createAnnotationHandler(progress, result);
            boolean calculateMergeinfo = myVcs.getSvnConfiguration().isShowMergeSourcesInAnnotate() && SvnUtil.checkRepositoryVersion15(myVcs, url);
            final MySteppedLogGetter logGetter = new MySteppedLogGetter(myVcs, ioFile, progress, myVcs.getFactory(ioFile).createHistoryClient(), endRevision, result, url, calculateMergeinfo, file.getCharset());
            logGetter.go();
            final LinkedList<SVNRevision> rp = logGetter.getRevisionPoints();
            // TODO: only 2 elements will be in rp and for loop will be executed only once - probably rewrite with Pair
            AnnotateClient annotateClient = myVcs.getFactory(ioFile).createAnnotateClient();
            for (int i = 0; i < rp.size() - 1; i++) {
                annotateClient.annotate(SvnTarget.fromFile(ioFile), rp.get(i + 1), rp.get(i), calculateMergeinfo, getLogClientOptions(myVcs), annotateHandler);
            }
            if (rp.get(1).getNumber() > 0) {
                result.setFirstRevision(rp.get(1));
            }
            annotation[0] = result;
        } catch (IOException e) {
            exception[0] = new VcsException(e);
        } catch (VcsException e) {
            if (e.getCause() instanceof SVNException) {
                handleSvnException(ioFile, info, (SVNException) e.getCause(), file, revision, annotation, exception);
            } else {
                exception[0] = e;
            }
        }
    };
    if (ApplicationManager.getApplication().isDispatchThread()) {
        ProgressManager.getInstance().runProcessWithProgressSynchronously(command, SvnBundle.message("action.text.annotate"), false, myVcs.getProject());
    } else {
        command.run();
    }
    if (exception[0] != null) {
        throw new VcsException(exception[0]);
    }
    return annotation[0];
}
Also used : SVNException(org.tmatesoft.svn.core.SVNException) IOException(java.io.IOException) Info(org.jetbrains.idea.svn.info.Info) LinkedList(java.util.LinkedList) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) VcsException(com.intellij.openapi.vcs.VcsException) SVNRevision(org.tmatesoft.svn.core.wc.SVNRevision) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile) File(java.io.File)

Example 49 with SVNException

use of org.tmatesoft.svn.core.SVNException in project intellij-community by JetBrains.

the class SvnKitAnnotateClient method annotate.

@Override
public void annotate(@NotNull SvnTarget target, @NotNull SVNRevision startRevision, @NotNull SVNRevision endRevision, boolean includeMergedRevisions, @Nullable DiffOptions diffOptions, @Nullable AnnotationConsumer handler) throws VcsException {
    try {
        SVNLogClient client = myVcs.getSvnKitManager().createLogClient();
        client.setDiffOptions(toDiffOptions(diffOptions));
        if (target.isFile()) {
            client.doAnnotate(target.getFile(), target.getPegRevision(), startRevision, endRevision, true, includeMergedRevisions, toAnnotateHandler(handler), null);
        } else {
            client.doAnnotate(target.getURL(), target.getPegRevision(), startRevision, endRevision, true, includeMergedRevisions, toAnnotateHandler(handler), null);
        }
    } catch (SVNException e) {
        throw new VcsException(e);
    }
}
Also used : VcsException(com.intellij.openapi.vcs.VcsException) SVNException(org.tmatesoft.svn.core.SVNException) SVNLogClient(org.tmatesoft.svn.core.wc.SVNLogClient)

Example 50 with SVNException

use of org.tmatesoft.svn.core.SVNException in project intellij-community by JetBrains.

the class SvnExceptionLogFilter method getKey.

@Override
public Object getKey(@NotNull Level level, @NonNls String message, @Nullable Throwable t, @NonNls String... details) {
    SVNException e = getSvnException(t);
    boolean shouldFilter = e != null && ourLogRarelyCodes.contains(e.getErrorMessage().getErrorCode());
    return shouldFilter ? e.getErrorMessage().getErrorCode() : null;
}
Also used : SVNException(org.tmatesoft.svn.core.SVNException)

Aggregations

SVNException (org.tmatesoft.svn.core.SVNException)95 File (java.io.File)37 SVNURL (org.tmatesoft.svn.core.SVNURL)37 VcsException (com.intellij.openapi.vcs.VcsException)18 SvnBindException (org.jetbrains.idea.svn.commandLine.SvnBindException)14 SVNConfigFile (org.tmatesoft.svn.core.internal.wc.SVNConfigFile)14 IOException (java.io.IOException)8 ArrayList (java.util.ArrayList)8 Collection (java.util.Collection)8 List (java.util.List)8 VirtualFile (com.intellij.openapi.vfs.VirtualFile)7 DefaultSVNOptions (org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions)7 SVNRepository (org.tmatesoft.svn.core.io.SVNRepository)7 SVNRevision (org.tmatesoft.svn.core.wc.SVNRevision)7 Date (java.util.Date)6 NotNull (org.jetbrains.annotations.NotNull)6 SVNCancelException (org.tmatesoft.svn.core.SVNCancelException)6 SVNLogEntry (org.tmatesoft.svn.core.SVNLogEntry)6 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)5 ByteArrayInputStream (java.io.ByteArrayInputStream)5