Search in sources :

Example 81 with SVNException

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

the class CreateBranchOrTagAction method perform.

@Override
protected void perform(@NotNull SvnVcs vcs, @NotNull VirtualFile file, @NotNull DataContext context) throws VcsException {
    CreateBranchOrTagDialog dialog = new CreateBranchOrTagDialog(vcs.getProject(), true, virtualToIoFile(file));
    if (dialog.showAndGet()) {
        String dstURL = dialog.getToURL();
        SVNRevision revision = dialog.getRevision();
        String comment = dialog.getComment();
        Ref<Exception> exception = new Ref<>();
        boolean isSrcFile = dialog.isCopyFromWorkingCopy();
        File srcFile = new File(dialog.getCopyFromPath());
        SVNURL srcUrl;
        SVNURL dstSvnUrl;
        SVNURL parentUrl;
        try {
            srcUrl = SVNURL.parseURIEncoded(dialog.getCopyFromUrl());
            dstSvnUrl = SVNURL.parseURIEncoded(dstURL);
            parentUrl = dstSvnUrl.removePathTail();
        } catch (SVNException e) {
            throw new SvnBindException(e);
        }
        if (!dirExists(vcs, parentUrl)) {
            int rc = Messages.showYesNoDialog(vcs.getProject(), "The repository path '" + parentUrl + "' does not exist. Would you like to create it?", "Branch or Tag", Messages.getQuestionIcon());
            if (rc == Messages.NO) {
                return;
            }
        }
        Runnable copyCommand = () -> {
            try {
                ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
                CommitEventHandler handler = null;
                if (progress != null) {
                    progress.setText(SvnBundle.message("progress.text.copy.to", dstURL));
                    handler = new IdeaCommitHandler(progress);
                }
                SvnTarget source = isSrcFile ? SvnTarget.fromFile(srcFile, revision) : SvnTarget.fromURL(srcUrl, revision);
                long newRevision = vcs.getFactory(source).createCopyMoveClient().copy(source, SvnTarget.fromURL(dstSvnUrl), revision, true, false, comment, handler);
                updateStatusBar(newRevision, vcs.getProject());
            } catch (Exception e) {
                exception.set(e);
            }
        };
        ProgressManager.getInstance().runProcessWithProgressSynchronously(copyCommand, SvnBundle.message("progress.title.copy"), false, vcs.getProject());
        if (!exception.isNull()) {
            throw new VcsException(exception.get());
        }
        if (dialog.isCopyFromWorkingCopy() && dialog.isSwitchOnCreate()) {
            SingleRootSwitcher switcher = new SingleRootSwitcher(vcs.getProject(), VcsUtil.getFilePath(srcFile, srcFile.isDirectory()), dstSvnUrl);
            AutoSvnUpdater.run(switcher, SvnBundle.message("action.name.switch"));
        }
    }
}
Also used : IdeaCommitHandler(org.jetbrains.idea.svn.checkin.IdeaCommitHandler) SVNURL(org.tmatesoft.svn.core.SVNURL) CommitEventHandler(org.jetbrains.idea.svn.checkin.CommitEventHandler) SVNException(org.tmatesoft.svn.core.SVNException) SingleRootSwitcher(org.jetbrains.idea.svn.update.SingleRootSwitcher) SvnBindException(org.jetbrains.idea.svn.commandLine.SvnBindException) VcsException(com.intellij.openapi.vcs.VcsException) SVNException(org.tmatesoft.svn.core.SVNException) Ref(com.intellij.openapi.util.Ref) SvnBindException(org.jetbrains.idea.svn.commandLine.SvnBindException) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) SvnTarget(org.tmatesoft.svn.core.wc2.SvnTarget) 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 82 with SVNException

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

the class SvnBindException method init.

private void init(@Nullable Throwable throwable) {
    if (throwable instanceof SVNException) {
        SVNException e = (SVNException) throwable;
        int code = e.getErrorMessage().getErrorCode().getCode();
        int type = e.getErrorMessage().getType();
        (type == SVNErrorMessage.TYPE_ERROR ? errors : warnings).putValue(code, e.getMessage());
    }
}
Also used : SVNException(org.tmatesoft.svn.core.SVNException)

Example 83 with SVNException

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

the class SvnKitContentClient method getContent.

@Override
public byte[] getContent(@NotNull SvnTarget target, @Nullable SVNRevision revision, @Nullable SVNRevision pegRevision) throws VcsException, FileTooBigRuntimeException {
    final int maxSize = VcsUtil.getMaxVcsLoadedFileSize();
    ByteArrayOutputStream buffer = new ByteArrayOutputStream() {

        @Override
        public synchronized void write(int b) {
            if (size() > maxSize)
                throw new FileTooBigRuntimeException();
            super.write(b);
        }

        @Override
        public synchronized void write(byte[] b, int off, int len) {
            if (size() > maxSize)
                throw new FileTooBigRuntimeException();
            super.write(b, off, len);
        }

        @Override
        public synchronized void writeTo(OutputStream out) throws IOException {
            if (size() > maxSize)
                throw new FileTooBigRuntimeException();
            super.writeTo(out);
        }
    };
    SVNWCClient wcClient = myVcs.getSvnKitManager().createWCClient();
    try {
        if (target.isURL()) {
            wcClient.doGetFileContents(target.getURL(), pegRevision, revision, true, buffer);
        } else {
            wcClient.doGetFileContents(target.getFile(), pegRevision, revision, true, buffer);
        }
        ContentRevisionCache.checkContentsSize(target.getPathOrUrlString(), buffer.size());
    } catch (FileTooBigRuntimeException e) {
        ContentRevisionCache.checkContentsSize(target.getPathOrUrlString(), buffer.size());
    } catch (SVNException e) {
        throw new VcsException(e);
    }
    return buffer.toByteArray();
}
Also used : OutputStream(java.io.OutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) VcsException(com.intellij.openapi.vcs.VcsException) SVNWCClient(org.tmatesoft.svn.core.wc.SVNWCClient) ByteArrayOutputStream(java.io.ByteArrayOutputStream) SVNException(org.tmatesoft.svn.core.SVNException)

Example 84 with SVNException

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

the class SvnKitCopyMoveClient method copy.

@Override
public void copy(@NotNull SvnTarget source, @NotNull File destination, @Nullable SVNRevision revision, boolean makeParents, @Nullable ProgressTracker handler) throws VcsException {
    SVNCopyClient client = myVcs.getSvnKitManager().createCopyClient();
    client.setEventHandler(toEventHandler(handler));
    try {
        client.doCopy(new SVNCopySource[] { createCopySource(source, revision) }, destination, false, makeParents, true);
    } catch (SVNException e) {
        throw new SvnBindException(e);
    }
}
Also used : SVNCopyClient(org.tmatesoft.svn.core.wc.SVNCopyClient) SvnBindException(org.jetbrains.idea.svn.commandLine.SvnBindException) SVNException(org.tmatesoft.svn.core.SVNException)

Example 85 with SVNException

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

the class SvnKitCopyMoveClient method copy.

@Override
public long copy(@NotNull SvnTarget source, @NotNull SvnTarget destination, @Nullable SVNRevision revision, boolean makeParents, boolean isMove, @NotNull String message, @Nullable CommitEventHandler handler) throws VcsException {
    if (!destination.isURL()) {
        throw new IllegalArgumentException("Only urls are supported as destination " + destination);
    }
    final SVNCopySource copySource = createCopySource(source, revision);
    SVNCopyClient client = myVcs.getSvnKitManager().createCopyClient();
    client.setEventHandler(toEventHandler(handler));
    SVNCommitInfo info;
    try {
        info = client.doCopy(new SVNCopySource[] { copySource }, destination.getURL(), isMove, makeParents, true, message, null);
    } catch (SVNException e) {
        throw new VcsException(e);
    }
    return info != null ? info.getNewRevision() : INVALID_REVISION;
}
Also used : SVNCopyClient(org.tmatesoft.svn.core.wc.SVNCopyClient) SVNCommitInfo(org.tmatesoft.svn.core.SVNCommitInfo) VcsException(com.intellij.openapi.vcs.VcsException) SVNException(org.tmatesoft.svn.core.SVNException) SVNCopySource(org.tmatesoft.svn.core.wc.SVNCopySource)

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