I'm using SVNKit to get the contents of a file from our repository. I would like to change that contents within the code and commit the changes back without having to checkout the file first. I searched the web already and only found solutions that require a checkout to the local file system.
Does anyone know a way for doing that?
Theoretically this should be feasible, but practical it seems to be impossible using SVNKit.
As far as I can see all check-in operations base directly or indirectly on org.tmatesoft.svn.core.wc.SVNCommitItem and this class requires a working copy file path in it's constructor.
You may be able to override this class and try to implement your own version which does not require a working-copy but I have not checked that in detail.
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.Don't forget, after getting a commit editor, to wrap everything up to
closeEdit()
in atry...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):
There isn't really a way. Fundamentally, SVN works on a checkout-edit-commit model. There may be apps that hide that away from you, but they'll still be performing a checkout to e.g. a temporary directory behind the scenes.
I just tried. You can get the bytes of the file to be modified. Change the contents in memory. Last, check in the code. Here is the sniped:
===================================================
==================================================
from svnkit sample code: