Search in sources :

Example 56 with SVNException

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

the class SvnParseCommandLineParseTest method testStatusInExternalMove.

public void testStatusInExternalMove() throws Exception {
    final String status = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<status>\n" + "<target\n" + "   path=\".\">\n" + "<entry\n" + "   path=\"slave\">\n" + "<wc-status\n" + "   item=\"external\"\n" + "   props=\"none\">\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"src\\com\\test\\just\">\n" + "<wc-status\n" + "   props=\"none\"\n" + "   item=\"unversioned\">\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\local2\\sep12main\\main\\slave\\src\\com\\slave\\MacMessagesParser.java\">\n" + "<wc-status\n" + "   item=\"added\"\n" + "   props=\"none\"\n" + "   copied=\"true\">\n" + "<commit\n" + "   revision=\"7\">\n" + "<author>admin</author>\n" + "<date>2012-09-12T12:16:51.621000Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\local2\\sep12main\\main\\slave\\src\\com\\slave\\SomeOtherClass.java\">\n" + "<wc-status\n" + "   props=\"none\"\n" + "   item=\"deleted\"\n" + "   revision=\"7\">\n" + "<commit\n" + "   revision=\"7\">\n" + "<author>admin</author>\n" + "<date>2012-09-12T12:16:51.621000Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "</target>\n" + "</status>";
    final String basePath = "C:\\TestProjects\\sortedProjects\\Subversion\\local2\\sep12main\\main";
    final SvnStatusHandler[] handler = new SvnStatusHandler[1];
    final File baseFile = new File(basePath);
    final SvnStatusHandler.ExternalDataCallback callback = CmdStatusClient.createStatusCallback(status1 -> {
        System.out.println(status1.getURL());
        if (new File("C:\\TestProjects\\sortedProjects\\Subversion\\local2\\sep12main\\main\\slave\\src\\com\\slave\\MacMessagesParser.java").equals(status1.getFile())) {
            Assert.assertEquals("http://external/src/com/slave/MacMessagesParser.java", status1.getURL().toString());
        }
        if (new File("C:\\TestProjects\\sortedProjects\\Subversion\\local2\\sep12main\\main\\slave\\src\\com\\slave\\SomeOtherClass.java").equals(status1.getFile())) {
            Assert.assertEquals("http://external/src/com/slave/SomeOtherClass.java", status1.getURL().toString());
        }
    }, baseFile, createStubInfo(basePath, "http://mainurl/"), handler);
    handler[0] = new SvnStatusHandler(callback, baseFile, o -> {
        try {
            if (new File("C:\\TestProjects\\sortedProjects\\Subversion\\local2\\sep12main\\main\\slave").equals(o)) {
                return createStubInfo(o.getPath(), "http://external");
            }
            return createStubInfo(o.getPath(), "http://12345");
        } catch (SVNException e) {
            throw new RuntimeException(e);
        }
    });
    SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
    parser.parse(new ByteArrayInputStream(status.getBytes(CharsetToolkit.UTF8_CHARSET)), handler[0]);
    final MultiMap<String, PortableStatus> changes = handler[0].getCurrentListChanges();
}
Also used : CmdStatusClient(org.jetbrains.idea.svn.status.CmdStatusClient) CharsetToolkit(com.intellij.openapi.vfs.CharsetToolkit) Date(java.util.Date) SAXParserFactory(javax.xml.parsers.SAXParserFactory) SvnInfoHandler(org.jetbrains.idea.svn.info.SvnInfoHandler) HashSet(java.util.HashSet) ByteArrayInputStream(java.io.ByteArrayInputStream) SAXParser(javax.xml.parsers.SAXParser) NodeKind(org.jetbrains.idea.svn.api.NodeKind) FileUtil(com.intellij.openapi.util.io.FileUtil) TestCase(junit.framework.TestCase) SvnStatusHandler(org.jetbrains.idea.svn.status.SvnStatusHandler) MultiMap(com.intellij.util.containers.MultiMap) SVNException(org.tmatesoft.svn.core.SVNException) StringUtil(com.intellij.openapi.util.text.StringUtil) PortableStatus(org.jetbrains.idea.svn.status.PortableStatus) Set(java.util.Set) Info(org.jetbrains.idea.svn.info.Info) IOException(java.io.IOException) SystemInfo(com.intellij.openapi.util.SystemInfo) File(java.io.File) Depth(org.jetbrains.idea.svn.api.Depth) SVNRevision(org.tmatesoft.svn.core.wc.SVNRevision) Assert(junit.framework.Assert) SVNURL(org.tmatesoft.svn.core.SVNURL) ByteArrayInputStream(java.io.ByteArrayInputStream) PortableStatus(org.jetbrains.idea.svn.status.PortableStatus) SvnStatusHandler(org.jetbrains.idea.svn.status.SvnStatusHandler) SAXParser(javax.xml.parsers.SAXParser) SVNException(org.tmatesoft.svn.core.SVNException) File(java.io.File)

Example 57 with SVNException

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

the class SvnParseCommandLineParseTest method testOneFileInChangeListStatus.

public void testOneFileInChangeListStatus() throws Exception {
    final String s = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<status>\n" + "<target\n" + "   path=\".\">\n" + "</target>\n" + "<changelist\n" + "   name=\"target\">\n" + "<entry\n" + "   path=\"a.txt\">\n" + "<wc-status\n" + "   props=\"none\"\n" + "   item=\"added\"\n" + "   revision=\"-1\">\n" + "</wc-status>\n" + "</entry>\n" + "</changelist>\n" + "</status>";
    final SvnStatusHandler[] handlerArr = new SvnStatusHandler[1];
    final boolean isWindows = SystemInfo.isWindows;
    final String basePath = isWindows ? "C:/base/" : "/base33729/";
    final Set<PortableStatus> statuses = new HashSet<>();
    final String[] clName = new String[1];
    final SvnStatusHandler handler = new SvnStatusHandler(new SvnStatusHandler.ExternalDataCallback() {

        @Override
        public void switchPath() {
            final PortableStatus pending = handlerArr[0].getPending();
            pending.setChangelistName(clName[0]);
            statuses.add(pending);
            pending.getKind();
        }

        @Override
        public void switchChangeList(String newList) {
            clName[0] = newList;
        }
    }, new File(basePath), o -> {
        try {
            o.getCanonicalFile();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        if (isWindows) {
            final int idx = o.getPath().indexOf(":");
            Assert.assertTrue(idx > 0);
            final int secondIdx = o.getPath().indexOf(":", idx + 1);
            Assert.assertTrue(o.getPath(), secondIdx == -1);
        } else {
            if (o.getPath().contains(LINUX_ROOT)) {
                Assert.assertFalse(o.getPath().contains(basePath));
            }
        }
        try {
            return createStubInfo(basePath + "1", "http://a.b.c");
        } catch (SVNException e) {
            throw new RuntimeException(e);
        }
    });
    handlerArr[0] = handler;
    final String osChecked = changePathsIfNix(s);
    SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
    parser.parse(new ByteArrayInputStream(osChecked.getBytes(CharsetToolkit.UTF8_CHARSET)), handler);
    Assert.assertEquals(1, statuses.size());
    final PortableStatus next = statuses.iterator().next();
    Assert.assertEquals("a.txt", next.getPath());
    Assert.assertEquals("target", next.getChangelistName());
}
Also used : PortableStatus(org.jetbrains.idea.svn.status.PortableStatus) IOException(java.io.IOException) SVNException(org.tmatesoft.svn.core.SVNException) ByteArrayInputStream(java.io.ByteArrayInputStream) SvnStatusHandler(org.jetbrains.idea.svn.status.SvnStatusHandler) SAXParser(javax.xml.parsers.SAXParser) File(java.io.File) HashSet(java.util.HashSet)

Example 58 with SVNException

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

the class SvnUpdateRootOptionsPanel method chooseBranch.

private void chooseBranch() {
    if (mySourceUrl == null) {
        myBranchField.setEnabled(false);
        return;
    }
    SelectBranchPopup.show(myVcs.getProject(), myRoot.getVirtualFile(), (project, configuration, url, revision) -> {
        // TODO: It seems that we could reuse configuration passed as parameter to this callback
        SvnBranchConfigurationNew branchConfiguration = getBranchConfiguration();
        String branchRelativeUrl = branchConfiguration != null ? branchConfiguration.getRelativeUrl(mySourceUrl.toString()) : null;
        if (mySourceUrl == null || branchRelativeUrl == null) {
            myBranchField.setText("");
        } else {
            try {
                myURLText.setText(SVNURL.parseURIEncoded(url).appendPath(branchRelativeUrl, true).toDecodedString());
            } catch (SVNException e) {
                LOG.error(e);
            }
            myBranchField.setText(SVNPathUtil.tail(url));
        }
    }, SvnBundle.message("select.branch.popup.general.title"), myPanel);
}
Also used : SVNException(org.tmatesoft.svn.core.SVNException) SvnBranchConfigurationNew(org.jetbrains.idea.svn.branchConfig.SvnBranchConfigurationNew)

Example 59 with SVNException

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

the class SvnKitUpgradeClient method upgrade.

@Override
public void upgrade(@NotNull File path, @NotNull WorkingCopyFormat format, @Nullable ProgressTracker handler) throws VcsException {
    validateFormat(format, getSupportedFormats());
    SVNWCClient client = myVcs.getSvnKitManager().createUpgradeClient();
    client.setEventHandler(toEventHandler(handler));
    try {
        cleanupIfNecessary(path, format, client, handler);
        upgrade(path, format, client, handler);
    } catch (SVNException e) {
        throw new SvnBindException(e);
    }
}
Also used : SvnBindException(org.jetbrains.idea.svn.commandLine.SvnBindException) SVNWCClient(org.tmatesoft.svn.core.wc.SVNWCClient) SVNException(org.tmatesoft.svn.core.SVNException)

Example 60 with SVNException

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

the class SvnAuthenticationTest method testWhenPassSaveNoInServers.

public void testWhenPassSaveNoInServers() throws Exception {
    final TestListener listener = new TestListener(mySynchObject);
    myAuthenticationManager.addListener(listener);
    final SavedOnceListener savedOnceListener = new SavedOnceListener();
    myAuthenticationManager.addListener(savedOnceListener);
    final File servers = new File(myConfiguration.getConfigurationDirectory(), "servers");
    final File oldServers = new File(myConfiguration.getConfigurationDirectory(), "config_old");
    FileUtil.copy(servers, oldServers);
    try {
        FileUtil.appendToFile(servers, "\nstore-passwords=no\n");
        final SVNURL url = SVNURL.parseURIEncoded("http://some.host.com/repo");
        final SVNException[] exception = new SVNException[1];
        final Boolean[] result = new Boolean[1];
        synchronousBackground(() -> {
            try {
                listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.request));
                listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
                listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.without_pasword_save));
                commonScheme(url, false, null);
                Assert.assertEquals(3, listener.getCnt());
                Assert.assertEquals(1, myTestInteraction.getNumPasswordsWarn());
                myTestInteraction.reset();
                savedOnceListener.assertForAwt();
                savedOnceListener.reset();
                SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
                listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.request));
                listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
                listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.without_pasword_save));
                commonScheme(url, false, null);
                Assert.assertEquals(6, listener.getCnt());
                Assert.assertEquals(1, myTestInteraction.getNumPasswordsWarn());
            } catch (SVNException e) {
                exception[0] = e;
            }
            result[0] = true;
        });
        Assert.assertTrue(result[0]);
        Assert.assertEquals(1, myTestInteraction.getNumPasswordsWarn());
        Assert.assertEquals(6, listener.getCnt());
        listener.assertForAwt();
        savedOnceListener.assertForAwt();
        savedOnceListener.assertSaved(url, ISVNAuthenticationManager.PASSWORD);
        if (exception[0] != null) {
            throw exception[0];
        }
    } finally {
        FileUtil.delete(servers);
        FileUtil.rename(oldServers, servers);
    }
}
Also used : SVNURL(org.tmatesoft.svn.core.SVNURL) SVNException(org.tmatesoft.svn.core.SVNException) SVNConfigFile(org.tmatesoft.svn.core.internal.wc.SVNConfigFile) 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