Search in sources :

Example 76 with SVNException

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

the class SvnKitMergeClient method merge.

public void merge(@NotNull SvnTarget source, @NotNull File destination, boolean dryRun, boolean reintegrate, @Nullable DiffOptions diffOptions, @Nullable ProgressTracker handler) throws VcsException {
    assertUrl(source);
    SVNDiffClient client = createClient(diffOptions, handler);
    try {
        if (reintegrate) {
            client.doMergeReIntegrate(source.getURL(), source.getPegRevision(), destination, dryRun);
        } else {
            client.doMerge(source.getURL(), source.getPegRevision(), ALL_REVISIONS_RANGE, destination, SVNDepth.UNKNOWN, true, false, dryRun, false);
        }
    } catch (SVNException e) {
        throw new VcsException(e);
    }
}
Also used : VcsException(com.intellij.openapi.vcs.VcsException) SVNException(org.tmatesoft.svn.core.SVNException) SVNDiffClient(org.tmatesoft.svn.core.wc.SVNDiffClient)

Example 77 with SVNException

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

the class SvnKitAdminAreaFactorySelector method getEnabledFactories.

public Collection getEnabledFactories(File path, Collection factories, boolean writeAccess) throws SVNException {
    if (ApplicationManager.getApplication().isUnitTestMode()) {
        return factories;
    }
    if (!writeAccess) {
        return factories;
    }
    Collection result = null;
    final WorkingCopyFormat presetFormat = SvnWorkingCopyFormatHolder.getPresetFormat();
    if (presetFormat != null) {
        result = format2Factories(presetFormat, factories);
    }
    if (result == null) {
        final WorkingCopyFormat format = SvnFormatSelector.getWorkingCopyFormat(path);
        result = format2Factories(format, factories);
    }
    if (result == null) {
        throw new SVNException(SVNErrorMessage.create(SVNErrorCode.WC_NOT_DIRECTORY));
    }
    return result;
}
Also used : WorkingCopyFormat(org.jetbrains.idea.svn.WorkingCopyFormat) Collection(java.util.Collection) SVNException(org.tmatesoft.svn.core.SVNException)

Example 78 with SVNException

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

the class SvnAuthenticationManager method checkHostGroup.

public static boolean checkHostGroup(final String url, final String patterns, final String exceptions) {
    final SVNURL svnurl;
    try {
        svnurl = SVNURL.parseURIEncoded(url);
    } catch (SVNException e) {
        return false;
    }
    final String host = svnurl.getHost();
    return matches(patterns, host) && (!matches(exceptions, host));
}
Also used : SVNURL(org.tmatesoft.svn.core.SVNURL) SVNException(org.tmatesoft.svn.core.SVNException)

Example 79 with SVNException

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

the class SvnKitCheckinClient method commit.

@NotNull
@Override
public CommitInfo[] commit(@NotNull List<File> paths, @NotNull String comment) throws VcsException {
    File[] pathsToCommit = ArrayUtil.toObjectArray(paths, File.class);
    boolean keepLocks = myVcs.getSvnConfiguration().isKeepLocks();
    SVNCommitPacket[] commitPackets = null;
    SVNCommitInfo[] results;
    SVNCommitClient committer = myVcs.getSvnKitManager().createCommitClient();
    IdeaCommitHandler handler = new IdeaCommitHandler(ProgressManager.getInstance().getProgressIndicator(), true, true);
    committer.setEventHandler(toEventHandler(handler));
    try {
        commitPackets = committer.doCollectCommitItems(pathsToCommit, keepLocks, true, SVNDepth.EMPTY, true, null);
        results = committer.doCommit(commitPackets, keepLocks, comment);
        commitPackets = null;
    } catch (SVNException e) {
        throw new SvnBindException(e);
    } finally {
        if (commitPackets != null) {
            for (SVNCommitPacket commitPacket : commitPackets) {
                try {
                    commitPacket.dispose();
                } catch (SVNException e) {
                    LOG.info(e);
                }
            }
        }
    }
    // This seems to be necessary only for SVNKit as changes after command line operations should be detected during VFS refresh.
    for (VirtualFile f : handler.getDeletedFiles()) {
        f.putUserData(VirtualFile.REQUESTOR_MARKER, this);
    }
    return convert(results);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) SVNCommitPacket(org.tmatesoft.svn.core.wc.SVNCommitPacket) SvnBindException(org.jetbrains.idea.svn.commandLine.SvnBindException) SVNCommitInfo(org.tmatesoft.svn.core.SVNCommitInfo) SVNCommitClient(org.tmatesoft.svn.core.wc.SVNCommitClient) SVNException(org.tmatesoft.svn.core.SVNException) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Example 80 with SVNException

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

the class SvnCheckoutProvider method checkout.

public static void checkout(final Project project, final File target, final String url, final SVNRevision revision, final Depth depth, final boolean ignoreExternals, final Listener listener, final WorkingCopyFormat selectedFormat) {
    final Ref<Boolean> checkoutSuccessful = new Ref<>();
    final Exception[] exception = new Exception[1];
    final Task.Backgroundable checkoutBackgroundTask = new Task.Backgroundable(project, message("message.title.check.out"), true, VcsConfiguration.getInstance(project).getCheckoutOption()) {

        public void run(@NotNull final ProgressIndicator indicator) {
            final WorkingCopyFormat format = selectedFormat == null ? UNKNOWN : selectedFormat;
            SvnWorkingCopyFormatHolder.setPresetFormat(format);
            SvnVcs vcs = SvnVcs.getInstance(project);
            ProgressTracker handler = new CheckoutEventHandler(vcs, false, ProgressManager.getInstance().getProgressIndicator());
            ProgressManager.progress(message("progress.text.checking.out", target.getAbsolutePath()));
            try {
                getFactory(vcs, format).createCheckoutClient().checkout(SvnTarget.fromURL(SVNURL.parseURIEncoded(url)), target, revision, depth, ignoreExternals, true, format, handler);
                ProgressManager.checkCanceled();
                checkoutSuccessful.set(Boolean.TRUE);
            } catch (SVNCancelException ignore) {
            } catch (SVNException | VcsException e) {
                exception[0] = e;
            } finally {
                SvnWorkingCopyFormatHolder.setPresetFormat(null);
            }
        }

        public void onCancel() {
            onSuccess();
        }

        public void onSuccess() {
            if (exception[0] != null) {
                showErrorDialog(message("message.text.cannot.checkout", exception[0].getMessage()), message("message.title.check.out"));
            }
            VirtualFile vf = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(target);
            if (vf != null) {
                vf.refresh(true, true, () -> getApplication().invokeLater(() -> notifyListener()));
            } else {
                notifyListener();
            }
        }

        private void notifyListener() {
            notifyRootManagerIfUnderProject(project, target);
            if (listener != null) {
                if (!checkoutSuccessful.isNull()) {
                    listener.directoryCheckedOut(target, SvnVcs.getKey());
                }
                listener.checkoutCompleted();
            }
        }
    };
    ProgressManager.getInstance().run(checkoutBackgroundTask);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Task(com.intellij.openapi.progress.Task) WorkingCopyFormat(org.jetbrains.idea.svn.WorkingCopyFormat) ProgressTracker(org.jetbrains.idea.svn.api.ProgressTracker) SVNException(org.tmatesoft.svn.core.SVNException) NotNull(org.jetbrains.annotations.NotNull) VcsException(com.intellij.openapi.vcs.VcsException) SVNCancelException(org.tmatesoft.svn.core.SVNCancelException) SVNException(org.tmatesoft.svn.core.SVNException) SvnVcs(org.jetbrains.idea.svn.SvnVcs) Ref(com.intellij.openapi.util.Ref) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) SVNCancelException(org.tmatesoft.svn.core.SVNCancelException) VcsException(com.intellij.openapi.vcs.VcsException)

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