« Return to Thread: Mirroring svn functionality with SVNKit

Re: Mirroring svn functionality with SVNKit

by quadelirus :: Rate this Message:

Reply to Author | View in Thread

Thanks,

I changed this code but I am still getting the Malformed network data error.

Here are the relevant bits of the stack trace:

org.tmatesoft.svn.core.SVNException: svn: Malformed network data
        at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(SVNErrorManager.java:64)
        at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(SVNErrorManager.java:51)
        at org.tmatesoft.svn.core.internal.io.svn.SVNReader.readChar(SVNReader.java:467)
        at org.tmatesoft.svn.core.internal.io.svn.SVNReader.skipWhiteSpace(SVNReader.java:479)
        at org.tmatesoft.svn.core.internal.io.svn.SVNReader.readTuple(SVNReader.java:281)
        at org.tmatesoft.svn.core.internal.io.svn.SVNReader.parse(SVNReader.java:235)
        at org.tmatesoft.svn.core.internal.io.svn.SVNConnection.read(SVNConnection.java:260)
        at org.tmatesoft.svn.core.internal.io.svn.SVNCommitEditor.closeEdit(SVNCommitEditor.java:203)

Alexander Sinyushkin wrote:
Hi John,

Here

 > svnEditor.openRoot(-1);
 > svnEditor.openFile(svnConfigurationPage.getProjectName() +
 > "/trunk/test.txt", -1);

you can not open files this way. It must be done in sequence opening all
the intermediate directories:

svnEditor.openRoot(-1);
svnEditor.openDir(svnConfigurationPage.getProjectName()...);
svnEditor.openDir(svnConfigurationPage.getProjectName()+"/trunk"...);
svnEditor.openFile(svnConfigurationPage.getProjectName() +
"/trunk/test.txt",..);
...

----
Alexander Sinyushkin,
TMate Software,
http://svnkit.com/ - Java [Sub]Versioning Library!

quadelirus wrote:
> Below is how I'm currently trying to mirror what I was doing before. Every
> thing works up to the svn commit comment. I'm trying to use the low level
> API still so that I don't have to write to the filesystem. My files will be
> generated by strings. The code below appropriately sets up my SVN project
> and writes the first version of test.txt to the trunk/ directory (which
> reads "This is a test document").
>
> When I try to commit a change to this document, namely to make it "This is a
> test document for SVN." I get an svn: Malformed network data error.
>
> I would really like to just use strings and not have to write them out to
> the file system since that is how I get the file versions from my existing
> versioning control system.
>
> If I can get this commit working, I'll have everything I need to migrate my
> stuff to SVN.
>
> Thanks,
> John
>
> //Setup the repository:
> SVNRepositoryFactoryImpl.setup();
> SVNRepository repository;
> repository = SVNRepositoryFactory.create(SVNURL.parseURIEncoded(serverURL),
> null);
>
> //Authenticate:
> ISVNAuthenticationManager authManager =
> SVNWCUtil.createDefaultAuthenticationManager(username, password);
> repository.setAuthenticationManager(authManager);
>
> //Create the ISVNEditor and SVNDeltaGenerator objects
> ISVNEditor svnEditor = repository.getCommitEditor("log message", null, true,
> null);
> SVNDeltaGenerator deltaGenerator = new SVNDeltaGenerator();
>
> //svn import (creates project/trunk, project/branches and project/tags)
> svnEditor.openRoot(-1);
> svnEditor.addDir(svnConfigurationPage.getProjectName(), null, -1);
> svnEditor.addDir(svnConfigurationPage.getProjectName() + "/trunk", null,
> -1);
> svnEditor.closeDir();
> svnEditor.addDir(svnConfigurationPage.getProjectName() + "/branches", null,
> -1);
> svnEditor.closeDir();
> svnEditor.addDir(svnConfigurationPage.getProjectName() + "/tags", null, -1);
> svnEditor.closeDir();
> svnEditor.closeDir();
> svnEditor.closeDir();
> svnEditor.closeEdit();
>
> //svn add (adds project/trunk/test.txt)
> svnEditor = repository.getCommitEditor("log message", null, true, null);
> svnEditor.openRoot(-1);
> svnEditor.addFile(svnConfigurationPage.getProjectName() + "/trunk/test.txt",
> null, -1);
> svnEditor.applyTextDelta(svnConfigurationPage.getProjectName() +
> "/trunk/test.txt", null);
> InputStream contentsStream = new ByteArrayInputStream("This is a test
> document".getBytes("UTF-8"));
> String checkSum =
> deltaGenerator.sendDelta(svnConfigurationPage.getProjectName() +
> "/trunk/test.txt", contentsStream, svnEditor, true);
> svnEditor.closeFile(svnConfigurationPage.getProjectName() +
> "/trunk/test.txt", checkSum);
> svnEditor.closeDir();
> svnEditor.closeEdit();
>
> //svn commit (commits a change to project/trunk/test.txt--NOT WORKING)
> svnEditor = repository.getCommitEditor("log message", null, true, null);
> svnEditor.openRoot(-1);
> svnEditor.openFile(svnConfigurationPage.getProjectName() +
> "/trunk/test.txt", -1);
> svnEditor.applyTextDelta(svnConfigurationPage.getProjectName() +
> "/trunk/test.txt", null);
> contentsStream = new ByteArrayInputStream("This is a test
> document".getBytes("UTF-8"));
> InputStream contentsStream2 = new ByteArrayInputStream("This is a test
> document for SVN.".getBytes("UTF-8"));
> checkSum = deltaGenerator.sendDelta(svnConfigurationPage.getProjectName() +
> "/trunk/test/txt", contentsStream, 0, contentsStream2, svnEditor, true);
> svnEditor.closeFile(svnConfigurationPage.getProjectName() +
> "/trunk/test/txt", checkSum);
> svnEditor.closeDir();
> svnEditor.closeEdit();

---------------------------------------------------------------------
To unsubscribe, e-mail: svnkit-users-unsubscribe@svnkit.com
For additional commands, e-mail: svnkit-users-help@svnkit.com

 « Return to Thread: Mirroring svn functionality with SVNKit