Search in sources :

Example 71 with SVNException

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

the class CopyOptionsDialog method update.

private void update() {
    RepositoryTreeNode baseNode = myBrowser.getSelectedNode();
    if (baseNode == null) {
        myTargetURL.setText("");
        getOKAction().setEnabled(false);
        return;
    }
    SVNURL baseURL = baseNode.getURL();
    String name = myNameField.getText();
    if (name == null || "".equals(name)) {
        getOKAction().setEnabled(false);
        return;
    }
    try {
        baseURL = baseURL.appendPath(myNameField.getText(), false);
    } catch (SVNException e) {
        //
        getOKAction().setEnabled(false);
        return;
    }
    myTargetURL.setText(baseURL.toString());
    getOKAction().setEnabled(!myURL.toString().equals(myTargetURL.getText()));
}
Also used : RepositoryTreeNode(org.jetbrains.idea.svn.dialogs.RepositoryTreeNode) SVNURL(org.tmatesoft.svn.core.SVNURL) SVNException(org.tmatesoft.svn.core.SVNException)

Example 72 with SVNException

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

the class CmdHistoryClient method doLog.

@Override
public void doLog(@NotNull SvnTarget target, @NotNull SVNRevision startRevision, @NotNull SVNRevision endRevision, boolean stopOnCopy, boolean discoverChangedPaths, boolean includeMergedRevisions, long limit, @Nullable String[] revisionProperties, @Nullable LogEntryConsumer handler) throws VcsException {
    // TODO: add revision properties parameter if necessary
    List<String> parameters = prepareCommand(target, startRevision, endRevision, stopOnCopy, discoverChangedPaths, includeMergedRevisions, limit);
    try {
        CommandExecutor command = execute(myVcs, target, SvnCommandName.log, parameters, null);
        // TODO: handler should be called in parallel with command execution, but this will be in other thread
        // TODO: check if that is ok for current handler implementation
        parseOutput(command, handler);
    } catch (SVNException e) {
        throw new SvnBindException(e);
    }
}
Also used : SvnBindException(org.jetbrains.idea.svn.commandLine.SvnBindException) CommandExecutor(org.jetbrains.idea.svn.commandLine.CommandExecutor) SVNException(org.tmatesoft.svn.core.SVNException)

Example 73 with SVNException

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

the class SyntheticWorker method removeSelf.

public void removeSelf() {
    final String parentUrl;
    try {
        parentUrl = myUrl.removePathTail().toString();
    } catch (SVNException e) {
        return;
    }
    final List<DirectoryEntry> children = myCache.getChildren(parentUrl);
    if (children == null) {
        return;
    }
    for (Iterator<DirectoryEntry> iterator = children.iterator(); iterator.hasNext(); ) {
        final DirectoryEntry entry = iterator.next();
        if (myUrl.equals(entry.getUrl())) {
            iterator.remove();
        }
    }
    myCache.put(parentUrl, children);
}
Also used : SVNException(org.tmatesoft.svn.core.SVNException) DirectoryEntry(org.jetbrains.idea.svn.browse.DirectoryEntry)

Example 74 with SVNException

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

the class CmdStatusClient method parseResult.

private void parseResult(final File path, SVNRevision revision, StatusConsumer handler, File base, Info infoBase, CommandExecutor command) throws SvnBindException {
    String result = command.getOutput();
    if (StringUtil.isEmptyOrSpaces(result)) {
        throw new SvnBindException("Status request returned nothing for command: " + command.getCommandText());
    }
    try {
        final SvnStatusHandler[] svnHandl = new SvnStatusHandler[1];
        svnHandl[0] = createStatusHandler(revision, handler, base, infoBase, svnHandl);
        SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
        parser.parse(new ByteArrayInputStream(result.trim().getBytes(CharsetToolkit.UTF8_CHARSET)), svnHandl[0]);
        if (!svnHandl[0].isAnythingReported()) {
            if (!SvnUtil.isSvnVersioned(myVcs, path)) {
                throw new SvnBindException(SVNErrorCode.WC_NOT_DIRECTORY, "Command - " + command.getCommandText() + ". Result - " + result);
            } else {
                // return status indicating "NORMAL" state
                // typical output would be like
                // <status>
                // <target path="1.txt"></target>
                // </status>
                // so it does not contain any <entry> element and current parsing logic returns null
                PortableStatus status = new PortableStatus();
                status.setFile(path);
                status.setPath(path.getAbsolutePath());
                status.setContentsStatus(StatusType.STATUS_NORMAL);
                status.setInfoGetter(() -> createInfoGetter(null).convert(path));
                try {
                    handler.consume(status);
                } catch (SVNException e) {
                    throw new SvnBindException(e);
                }
            }
        }
    } catch (SvnExceptionWrapper e) {
        throw new SvnBindException(e.getCause());
    } catch (IOException | ParserConfigurationException e) {
        throw new SvnBindException(e);
    } catch (SAXException e) {
        // status parsing errors are logged separately as sometimes there are parsing errors connected to terminal output handling.
        // these errors primarily occur when status output is rather large.
        // and status output could be large, for instance, when working copy is locked (seems that each file is listed in status output).
        command.logCommand();
        throw new SvnBindException(e);
    }
}
Also used : SVNException(org.tmatesoft.svn.core.SVNException) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException) ByteArrayInputStream(java.io.ByteArrayInputStream) SAXParser(javax.xml.parsers.SAXParser) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException)

Example 75 with SVNException

use of org.tmatesoft.svn.core.SVNException 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)

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