Search in sources :

Example 26 with SvnBindException

use of org.jetbrains.idea.svn.commandLine.SvnBindException in project intellij-community by JetBrains.

the class ChangesChecker method gather.

public void gather(final List<Change> changes) {
    final TreeMap<String, File> renames = new TreeMap<>();
    final Set<String> alsoReverted = new HashSet<>();
    final Map<String, FilePath> files = new HashMap<>();
    for (Change change : changes) {
        final ContentRevision beforeRevision = change.getBeforeRevision();
        final ContentRevision afterRevision = change.getAfterRevision();
        final String key = afterRevision == null ? null : FilePathsHelper.convertWithLastSeparator(afterRevision.getFile());
        if (SvnRollbackEnvironment.isMoveRenameReplace(change)) {
            final File beforeFile = beforeRevision.getFile().getIOFile();
            renames.put(key, beforeFile);
            files.put(key, afterRevision.getFile());
            myCollector.markRename(beforeFile, afterRevision.getFile().getIOFile());
        } else if (afterRevision != null) {
            alsoReverted.add(key);
        }
    }
    if (!renames.isEmpty()) {
        final ArrayList<String> paths = new ArrayList<>(renames.keySet());
        if (paths.size() > 1) {
            FilterFilePathStrings.getInstance().doFilter(paths);
        }
        myCollector.setRenamesMap(renames);
        myCollector.setAlsoReverted(alsoReverted);
        for (String path : paths) {
            try {
                myChangeProvider.getChanges(files.get(path), true, myCollector);
            } catch (SVNException e) {
                myExceptions.add(new VcsException(e));
            } catch (SvnBindException e) {
                myExceptions.add(e);
            }
        }
    }
    for (Change change : changes) {
        final ContentRevision afterRevision = change.getAfterRevision();
        boolean checked = myForAdds.accept(change);
        checked |= myForDeletes.accept(change);
        if (!checked) {
            myForEdits.add(afterRevision.getFile().getIOFile());
        }
    }
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) ContentRevision(com.intellij.openapi.vcs.changes.ContentRevision) Change(com.intellij.openapi.vcs.changes.Change) SVNException(org.tmatesoft.svn.core.SVNException) SvnBindException(org.jetbrains.idea.svn.commandLine.SvnBindException) VcsException(com.intellij.openapi.vcs.VcsException) File(java.io.File)

Example 27 with SvnBindException

use of org.jetbrains.idea.svn.commandLine.SvnBindException in project intellij-community by JetBrains.

the class SvnKitBrowseClient method list.

@Override
public void list(@NotNull SvnTarget target, @Nullable SVNRevision revision, @Nullable Depth depth, @Nullable DirectoryEntryConsumer handler) throws VcsException {
    assertUrl(target);
    SVNLogClient client = getLogClient();
    ISVNDirEntryHandler wrappedHandler = wrapHandler(handler);
    client.setIgnoreExternals(true);
    try {
        if (target.isFile()) {
            client.doList(target.getFile(), target.getPegRevision(), notNullize(revision), true, toDepth(depth), SVNDirEntry.DIRENT_ALL, wrappedHandler);
        } else {
            client.doList(target.getURL(), target.getPegRevision(), notNullize(revision), true, toDepth(depth), SVNDirEntry.DIRENT_ALL, wrappedHandler);
        }
    } catch (SVNException e) {
        throw new SvnBindException(e);
    }
}
Also used : SvnBindException(org.jetbrains.idea.svn.commandLine.SvnBindException) SVNLogClient(org.tmatesoft.svn.core.wc.SVNLogClient)

Example 28 with SvnBindException

use of org.jetbrains.idea.svn.commandLine.SvnBindException 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 29 with SvnBindException

use of org.jetbrains.idea.svn.commandLine.SvnBindException 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 30 with SvnBindException

use of org.jetbrains.idea.svn.commandLine.SvnBindException 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)

Aggregations

SvnBindException (org.jetbrains.idea.svn.commandLine.SvnBindException)32 SVNException (org.tmatesoft.svn.core.SVNException)13 NotNull (org.jetbrains.annotations.NotNull)7 VirtualFile (com.intellij.openapi.vfs.VirtualFile)6 File (java.io.File)6 CommandExecutor (org.jetbrains.idea.svn.commandLine.CommandExecutor)5 SVNURL (org.tmatesoft.svn.core.SVNURL)5 FilePath (com.intellij.openapi.vcs.FilePath)4 VcsException (com.intellij.openapi.vcs.VcsException)4 VfsUtilCore.virtualToIoFile (com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)4 IOException (java.io.IOException)4 SVNRevision (org.tmatesoft.svn.core.wc.SVNRevision)4 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)3 Change (com.intellij.openapi.vcs.changes.Change)3 ContentRevision (com.intellij.openapi.vcs.changes.ContentRevision)3 ArrayList (java.util.ArrayList)3 ConfigurationException (com.intellij.openapi.options.ConfigurationException)2 Ref (com.intellij.openapi.util.Ref)2 FileStatus (com.intellij.openapi.vcs.FileStatus)2 Nullable (org.jetbrains.annotations.Nullable)2