Question

I use SVNKit to check in files from one SVN Repo. to another.

My problem is that

the version of the target svn increase with every file.

ex: I check out 5 files from Repo. A to Repo. B under one commitment. And I expect the version of Repo. B increased only one unit, but actually it turns to 5 units.

here is my code. "cubes" is used to restored the files information I want to check out.

for (int i=0; i<cubes.size();i++) {
    souRepo.getFile(cubes.get(i).getLocalPath()+"/"+cubes.get(i).getLocalFile(),cubes.get(i).getLocalVer(), fileProperties, baos);
    input  = new ByteArrayInputStream(baos.toByteArray() );
    SVNNodeKind nodeKind = tarRepo.checkPath( cubes.get(i).getLocalFile(),  -1 );
    editor = tarRepo.getCommitEditor(logMessage, new CommitMediator() );
    editor.openRoot(-1);

    if ( nodeKind == SVNNodeKind.NONE ) {
       editor.addFile(cubes.get(i).getLocalFile(), null, -1);
    } else {
       editor.openFile(cubes.get(i).getLocalFile(), -1);
    }   // end of else
    editor.applyTextDelta(cubes.get(i).getLocalFile(), null); 
    String baseChecksum = deltaGenerator.sendDelta(cubes.get(i).getLocalFile(), input, editor, true);
    editor.textDeltaEnd(cubes.get(i).getLocalFile() );
    editor.closeFile(cubes.get(i).getLocalFile(), baseChecksum);
    info =  editor.closeEdit();
}

Any idea would be appreciated~~

Était-ce utile?

La solution

The code shows that you commit one file per commit. Try something like this instead:

editor = tarRepo.getCommitEditor(logMessage, new CommitMediator() );
editor.openRoot(-1);
for (int i=0; i<cubes.size();i++) {
    souRepo.getFile(cubes.get(i).getLocalPath()+"/"+cubes.get(i).getLocalFile(),cubes.get(i).getLocalVer(), fileProperties, baos);
    input  = new ByteArrayInputStream(baos.toByteArray() );
    SVNNodeKind nodeKind = tarRepo.checkPath( cubes.get(i).getLocalFile(),  -1 );

    if ( nodeKind == SVNNodeKind.NONE ) {
       editor.addFile(cubes.get(i).getLocalFile(), null, -1);
    } else {
       editor.openFile(cubes.get(i).getLocalFile(), -1);
    }   // end of else
    editor.applyTextDelta(cubes.get(i).getLocalFile(), null); 
    String baseChecksum = deltaGenerator.sendDelta(cubes.get(i).getLocalFile(), input, editor, true);
    editor.textDeltaEnd(cubes.get(i).getLocalFile() );
    editor.closeFile(cubes.get(i).getLocalFile(), baseChecksum);
}
info =  editor.closeEdit();
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top