SVNCommitEditor.addFile() does not have any effect

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

SVNCommitEditor.addFile() does not have any effect

neuropa
This post has NOT been accepted by the mailing list yet.
Hi All,

I'm new to SVNKit and I'm not sure if I do something wrong in Java code or devenv differences make my life harder.

Previously I managed to get commit content from pre-commit hook and edit it into another repository. BUT my oroginal structure from source repo here:

[2016/10/31 15:37:38] Repository root: C:\Repositories\Test1
[2016/10/31 15:37:38] Transaction name: 81-3p
[2016/10/31 15:37:38] Add directory: /dir1
[2016/10/31 15:37:38] Add directory: /dir1/dir2
[2016/10/31 15:37:38] Add file: /dir1/file1.txt

or simply:

/dir1
/dir1/dir2
/dir1/file1.txt

somehow ended up like this:

/dir1
/dir1/dir2
/dir1/dir2/file1.txt

When I tried to find what's causing this bug-like behaviour, my test commit code started to ignore addFile() calls and I don't know why.

Here is a simple test piece which results in 2 added dirs and 0 added file in the target repo:

try
{
        final ISVNEditor editor = targetRepository.getCommitEditor( "TestOperation", null ); // 2 more params..0
        editor.openRoot( -1 );
        final String dirPath = "dirA";
        editor.addDir( dirPath, null, -1 );
        final String filePath = dirPath + "/filA.txt";
        final SVNDeltaGenerator deltaGenerator = new SVNDeltaGenerator();
        final String checkSum = deltaGenerator.sendDelta( filePath, new ByteArrayInputStream( "Some text content".getBytes() ), editor, true );
        editor.addFile( filePath, null, -1 );
        editor.openFile( filePath, -1 );
        editor.applyTextDelta( filePath, null );
        editor.closeFile( filePath, checkSum );
        editor.closeDir();
        editor.closeEdit();
}
catch ( final SVNException e )
{
        Logger.log( "'" + e.getErrorMessage().getErrorCode().getCode() + "'" );
        Logger.log( e.getMessage() );
        throw e;
}

Do you have any idea?

Thank You in advance!