I talked to the folks at TMate Software, and it seems this is indeed possible. The way they explained it, yes, you can use a local file and generate checksums with the new content and send that to Subversion, but (if anything) this is only going to help Subversion verify you have the correct and latest in your local copy. At the end of the day, Subversion is going to do its own diffs and deltas anyway.
So if you don't have a local copy, you can just create a checksum as if the file were new. Here's the rough code, extracted from my larger project. Note that checking the SVNDirEntry
ahead of time isn't required, if you already know whether the file exists; I'm providing it here for explanatory purposes.
SVNDirEntry dirEntry = svnRepository.info(filePath, -1);
ISVNEditor editor = svnRepository.getCommitEditor("example modification", null, true, null);
editor.openRoot(-1);
if(dirEntry.getKind() == SVNNodeKind.NONE)
{
editor.addFile(filePath, null, -1);
}
else
{
editor.openFile(filePath, -1);
}
editor.applyTextDelta(filePath, null);
final SVNDeltaGenerator deltaGenerator = new SVNDeltaGenerator();
final String checksum = deltaGenerator.sendDelta(filePath, inputStream, editor, true);
editor.closeFile(filePath, checksum);
editor.closeDir(); //close the root
editor.closeEdit();
Don't forget, after getting a commit editor, to wrap everything up to closeEdit()
in a try...catch
block so that you can abort the edit if something goes wrong.
I've tried this and it passes all my tests using SVNKIt 1.3.7 (e.g. from Maven):
<repositories>
<repository>
<id>svnkit-repository</id>
<name>SVNKit Repository</name>
<url>http://maven.tmatesoft.com/content/repositories/releases/</url>
</repository>
</repositories>
...
<dependency>
<groupId>org.tmatesoft.svnkit</groupId>
<artifactId>svnkit</artifactId>
<version>1.3.7</version>
</dependency>