Search in sources :

Example 1 with SvnStatusHandler

use of org.jetbrains.idea.svn.status.SvnStatusHandler in project intellij-community by JetBrains.

the class SvnParseCommandLineParseTest method testStatusWithSwitched.

public void testStatusWithSwitched() throws Exception {
    final String s = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<status>\n" + "<target\n" + "   path=\".\">\n" + "<entry\n" + "   path=\"root\\source\\s1.txt\">\n" + "<wc-status\n" + "   props=\"none\"\n" + "   switched=\"true\"\n" + "   item=\"normal\"\n" + "   revision=\"5\">\n" + "<commit\n" + "   revision=\"4\">\n" + "<author>Irina.Chernushina</author>\n" + "<date>2013-02-18T13:14:24.391537Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"root\\target\">\n" + "<wc-status\n" + "   props=\"none\"\n" + "   switched=\"true\"\n" + "   item=\"normal\"\n" + "   revision=\"5\">\n" + "<commit\n" + "   revision=\"4\">\n" + "<author>Irina.Chernushina</author>\n" + "<date>2013-02-18T13:14:24.391537Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "</target>\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 SvnStatusHandler handler = new SvnStatusHandler(new SvnStatusHandler.ExternalDataCallback() {

        @Override
        public void switchPath() {
            statuses.add(handlerArr[0].getPending());
            handlerArr[0].getPending().getKind();
        }

        @Override
        public void switchChangeList(String 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);
    final String[] expected = { "root\\source\\s1.txt", "root\\target" };
    for (int i = 0; i < expected.length; i++) {
        expected[i] = FileUtil.toSystemDependentName(expected[i]);
    }
    int cntMatched = 0;
    for (PortableStatus status : statuses) {
        Assert.assertTrue(status.isSwitched());
        final String path = FileUtil.toSystemDependentName(status.getPath());
        for (String s1 : expected) {
            if (s1.equals(path)) {
                ++cntMatched;
                break;
            }
        }
    }
    Assert.assertEquals(2, cntMatched);
}
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 2 with SvnStatusHandler

use of org.jetbrains.idea.svn.status.SvnStatusHandler in project intellij-community by JetBrains.

the class SvnParseCommandLineParseTest method testStatus.

public void testStatus() throws Exception {
    final String s = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<status>\n" + "<target\n" + "   path=\".\">\n" + "<entry\n" + "   path=\".\">\n" + "<wc-status\n" + "   props=\"normal\"\n" + "   item=\"incomplete\"\n" + "   revision=\"92339\">\n" + "<commit\n" + "   revision=\"91672\">\n" + "<author>qx</author>\n" + "<date>2012-01-27T16:11:06.069351Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"Decompiler\">\n" + "<wc-status\n" + "   props=\"none\"\n" + "   tree-conflicted=\"true\"\n" + "   item=\"missing\">\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"Help\">\n" + "<wc-status\n" + "   props=\"normal\"\n" + "   item=\"incomplete\"\n" + "   revision=\"92339\">\n" + "<commit\n" + "   revision=\"91555\">\n" + "<author>Egor.Malyshev</author>\n" + "<date>2012-01-18T18:05:07.328519Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"Help\\XML\">\n" + "<wc-status\n" + "   props=\"normal\"\n" + "   item=\"incomplete\"\n" + "   revision=\"92339\">\n" + "<commit\n" + "   revision=\"91555\">\n" + "<author>Egor.Malyshev</author>\n" + "<date>2012-01-18T18:05:07.328519Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"Help\\XML\\images\">\n" + "<wc-status\n" + "   props=\"normal\"\n" + "   item=\"incomplete\"\n" + "   revision=\"92339\">\n" + "<commit\n" + "   revision=\"91170\">\n" + "<author>Maria.Egorkina</author>\n" + "<date>2011-12-20T13:26:52.217550Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"Platform\">\n" + "<wc-status\n" + "   props=\"none\"\n" + "   item=\"external\">\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"ReSharper.ipr\">\n" + "<wc-status\n" + "   item=\"modified\"\n" + "   revision=\"91677\"\n" + "   props=\"normal\">\n" + "<commit\n" + "   revision=\"87631\">\n" + "<author>Alexey.Kuptsov</author>\n" + "<date>2011-09-30T11:25:10.391467Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"ReSharper.iws\">\n" + "<wc-status\n" + "   item=\"ignored\"\n" + "   props=\"none\">\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"measure.bat\">\n" + "<wc-status\n" + "   item=\"unversioned\"\n" + "   props=\"none\">\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"src\\Daemon\\src\\HighlightingBase.cs\">\n" + "<wc-status\n" + "   item=\"deleted\"\n" + "   revision=\"91677\"\n" + "   props=\"none\">\n" + "<commit\n" + "   revision=\"79264\">\n" + "<author>xvost</author>\n" + "<date>2011-02-05T16:06:12.116814Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"src\\Daemon\\src\\HighlightingBase1.cs\">\n" + "<wc-status\n" + "   props=\"none\"\n" + "   copied=\"true\"\n" + "   item=\"added\">\n" + "<commit\n" + "   revision=\"79264\">\n" + "<author>xvost</author>\n" + "<date>2011-02-05T16:06:12.116814Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"src\\Decompiler.Core\">\n" + "<wc-status\n" + "   item=\"added\"\n" + "   props=\"normal\"\n" + "   copied=\"true\"\n" + "   tree-conflicted=\"true\">\n" + "<commit\n" + "   revision=\"91559\">\n" + "<author>Leonid.Shalupov</author>\n" + "<date>2012-01-18T19:17:40.876383Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"src\\Decompiler.Core\\Src\\Transformations\\Loops\\EliminateRedundantContinueTransformation.cs\">\n" + "<wc-status\n" + "   props=\"normal\"\n" + "   copied=\"true\"\n" + "   item=\"modified\">\n" + "<commit\n" + "   revision=\"87972\">\n" + "<author>Slava.Trenogin</author>\n" + "<date>2011-10-06T21:27:41.539022Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"src\\Decompiler.Core\\Src\\Transformations\\StatementStructure\\ReduceReturnOrYieldBreakTransformation.cs\">\n" + "<wc-status\n" + "   item=\"modified\"\n" + "   props=\"normal\"\n" + "   copied=\"true\">\n" + "<commit\n" + "   revision=\"87972\">\n" + "<author>Slava.Trenogin</author>\n" + "<date>2011-10-06T21:27:41.539022Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"stat.txt\">\n" + "<wc-status\n" + "   props=\"none\"\n" + "   item=\"unversioned\">\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\CommonServices\\src\\Services\\CommonServices.cs\">\n" + "<wc-status\n" + "   item=\"modified\"\n" + "   revision=\"92564\"\n" + "   props=\"none\">\n" + "<commit\n" + "   revision=\"73708\">\n" + "<author>Leonid.Shalupov</author>\n" + "<date>2010-09-10T14:14:04.090943Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Document.Tests\\AssemblyInfo.cs\">\n" + "<wc-status\n" + "   item=\"modified\"\n" + "   revision=\"92564\"\n" + "   props=\"none\">\n" + "<commit\n" + "   revision=\"86795\">\n" + "<author>Leonid.Shalupov</author>\n" + "<date>2011-09-11T13:54:16.917943Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Document.Tests\\RangeMarkerTest.cs\">\n" + "<wc-status\n" + "   props=\"none\"\n" + "   item=\"modified\"\n" + "   revision=\"92564\">\n" + "<commit\n" + "   revision=\"77688\">\n" + "<author>Alexander.Zverev</author>\n" + "<date>2010-12-14T15:56:38.322018Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Metadata\\AssemblyInfo.cs\">\n" + "<wc-status\n" + "   item=\"modified\"\n" + "   revision=\"92564\"\n" + "   props=\"none\">\n" + "<commit\n" + "   revision=\"82127\">\n" + "<author>Leonid.Shalupov</author>\n" + "<date>2011-04-13T20:57:30.828600Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Metadata\\src\\Utils\\AssemblyNameInfo.cs\">\n" + "<wc-status\n" + "   item=\"modified\"\n" + "   revision=\"92564\"\n" + "   props=\"none\">\n" + "<commit\n" + "   revision=\"90865\">\n" + "<author>xvost</author>\n" + "<date>2011-12-13T13:10:30.902950Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Metadata\\src\\Utils\\BinaryBlobExtensions.cs\">\n" + "<wc-status\n" + "   item=\"modified\"\n" + "   revision=\"92564\"\n" + "   props=\"none\">\n" + "<commit\n" + "   revision=\"74075\">\n" + "<author>Leonid.Shalupov</author>\n" + "<date>2010-09-17T09:32:30.827654Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Metadata\\src\\Utils\\BinaryBlobReader.cs\">\n" + "<wc-status\n" + "   props=\"none\"\n" + "   item=\"modified\"\n" + "   revision=\"92564\">\n" + "<commit\n" + "   revision=\"74075\">\n" + "<author>Leonid.Shalupov</author>\n" + "<date>2010-09-17T09:32:30.827654Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Metadata\\src\\Utils\\BinaryBlobStream.cs\">\n" + "<wc-status\n" + "   props=\"none\"\n" + "   item=\"modified\"\n" + "   revision=\"92564\">\n" + "<commit\n" + "   revision=\"74075\">\n" + "<author>Leonid.Shalupov</author>\n" + "<date>2010-09-17T09:32:30.827654Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Metadata\\src\\Utils\\BlobOnReader.cs\">\n" + "<wc-status\n" + "   item=\"modified\"\n" + "   revision=\"92564\"\n" + "   props=\"none\">\n" + "<commit\n" + "   revision=\"74075\">\n" + "<author>Leonid.Shalupov</author>\n" + "<date>2010-09-17T09:32:30.827654Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Metadata\\src\\Utils\\ComStreamWrapper.cs\">\n" + "<wc-status\n" + "   item=\"modified\"\n" + "   revision=\"92564\"\n" + "   props=\"none\">\n" + "<commit\n" + "   revision=\"91348\">\n" + "<author>Sergey.Shkredov</author>\n" + "<date>2012-01-09T11:26:53.770349Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Metadata\\src\\Utils\\EmptyBlob.cs\">\n" + "<wc-status\n" + "   props=\"none\"\n" + "   item=\"modified\"\n" + "   revision=\"92564\">\n" + "<commit\n" + "   revision=\"74075\">\n" + "<author>Leonid.Shalupov</author>\n" + "<date>2010-09-17T09:32:30.827654Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Metadata\\src\\Utils\\GAC.cs\">\n" + "<wc-status\n" + "   props=\"normal\"\n" + "   item=\"modified\"\n" + "   revision=\"92564\">\n" + "<commit\n" + "   revision=\"75626\">\n" + "<author>Slava.Trenogin</author>\n" + "<date>2010-10-21T07:41:45.036722Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Metadata\\src\\Utils\\GacUtil.cs\">\n" + "<wc-status\n" + "   props=\"none\"\n" + "   item=\"modified\"\n" + "   revision=\"92564\">\n" + "<commit\n" + "   revision=\"91646\">\n" + "<author>Leonid.Shalupov</author>\n" + "<date>2012-01-21T19:08:04.108471Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Metadata\\src\\Utils\\IBinaryReader.cs\">\n" + "<wc-status\n" + "   item=\"modified\"\n" + "   revision=\"92564\"\n" + "   props=\"none\">\n" + "<commit\n" + "   revision=\"71390\">\n" + "<author>Leonid.Shalupov</author>\n" + "<date>2010-07-12T18:29:27.763006Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Metadata\\src\\Utils\\IntInterval.cs\">\n" + "<wc-status\n" + "   item=\"modified\"\n" + "   revision=\"92564\"\n" + "   props=\"none\">\n" + "<commit\n" + "   revision=\"55567\">\n" + "<author>qx</author>\n" + "<date>2009-06-03T10:11:14.985037Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Metadata\\src\\Utils\\ManifestResourceUtil.cs\">\n" + "<wc-status\n" + "   props=\"none\"\n" + "   item=\"modified\"\n" + "   revision=\"92564\">\n" + "<commit\n" + "   revision=\"87972\">\n" + "<author>Slava.Trenogin</author>\n" + "<date>2011-10-06T21:27:41.539022Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Metadata\\src\\Utils\\MarshalSpecParser.cs\">\n" + "<wc-status\n" + "   item=\"modified\"\n" + "   revision=\"92564\"\n" + "   props=\"none\">\n" + "<commit\n" + "   revision=\"76982\">\n" + "<author>Leonid.Shalupov</author>\n" + "<date>2010-11-28T10:16:36.309593Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Metadata\\src\\Utils\\MetadataHelpers.cs\">\n" + "<wc-status\n" + "   props=\"none\"\n" + "   item=\"modified\"\n" + "   revision=\"92564\">\n" + "<commit\n" + "   revision=\"91348\">\n" + "<author>Sergey.Shkredov</author>\n" + "<date>2012-01-09T11:26:53.770349Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Metadata\\src\\Utils\\ModuleQualificationUtil.cs\">\n" + "<wc-status\n" + "   props=\"none\"\n" + "   item=\"modified\"\n" + "   revision=\"92564\">\n" + "<commit\n" + "   revision=\"60918\">\n" + "<author>xvost</author>\n" + "<date>2009-11-03T10:42:37.363952Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Metadata\\src\\Utils\\StreamBinaryReader.cs\">\n" + "<wc-status\n" + "   item=\"modified\"\n" + "   revision=\"92564\"\n" + "   props=\"none\">\n" + "<commit\n" + "   revision=\"71390\">\n" + "<author>Leonid.Shalupov</author>\n" + "<date>2010-07-12T18:29:27.763006Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + "   path=\"C:\\TestProjects\\sortedProjects\\Subversion\\Resharper17short\\Platform\\src\\Metadata\\src\\Utils\\SubStream.cs\">\n" + "<wc-status\n" + "   item=\"modified\"\n" + "   revision=\"92564\"\n" + "   props=\"none\">\n" + "<commit\n" + "   revision=\"76725\">\n" + "<author>Leonid.Shalupov</author>\n" + "<date>2010-11-20T13:23:44.172899Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "</target>\n" + "<changelist\n" + "   name=\"ads\">\n" + "<entry\n" + "   path=\"BuildVsix.cmd\">\n" + "<wc-status\n" + "   item=\"modified\"\n" + "   revision=\"91677\"\n" + "   props=\"none\">\n" + "<commit\n" + "   revision=\"77579\">\n" + "<author>Victor.Kropp</author>\n" + "<date>2010-12-13T11:06:36.141754Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "</changelist>\n" + "</status>\n";
    final SvnStatusHandler[] handlerArr = new SvnStatusHandler[1];
    final boolean isWindows = SystemInfo.isWindows;
    final String basePath = isWindows ? "C:/base/" : "/base33729/";
    final SvnStatusHandler handler = new SvnStatusHandler(new SvnStatusHandler.ExternalDataCallback() {

        @Override
        public void switchPath() {
            handlerArr[0].getPending().getKind();
        }

        @Override
        public void switchChangeList(String 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);
    final MultiMap<String, PortableStatus> changes = handler.getCurrentListChanges();
}
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)

Example 3 with SvnStatusHandler

use of org.jetbrains.idea.svn.status.SvnStatusHandler 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 4 with SvnStatusHandler

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

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)4 File (java.io.File)4 IOException (java.io.IOException)4 SAXParser (javax.xml.parsers.SAXParser)4 PortableStatus (org.jetbrains.idea.svn.status.PortableStatus)4 SvnStatusHandler (org.jetbrains.idea.svn.status.SvnStatusHandler)4 SVNException (org.tmatesoft.svn.core.SVNException)4 HashSet (java.util.HashSet)3 SystemInfo (com.intellij.openapi.util.SystemInfo)1 FileUtil (com.intellij.openapi.util.io.FileUtil)1 StringUtil (com.intellij.openapi.util.text.StringUtil)1 CharsetToolkit (com.intellij.openapi.vfs.CharsetToolkit)1 MultiMap (com.intellij.util.containers.MultiMap)1 Date (java.util.Date)1 Set (java.util.Set)1 SAXParserFactory (javax.xml.parsers.SAXParserFactory)1 Assert (junit.framework.Assert)1 TestCase (junit.framework.TestCase)1 Depth (org.jetbrains.idea.svn.api.Depth)1 NodeKind (org.jetbrains.idea.svn.api.NodeKind)1