SVNKit SvnRemoteXXX operations: one more common mistake

I’d like to describe one more mistake that one can encounter into while using SVNKit. Suppose you want to copy a file from a working copy to the repository directly. You write code like:

file File file = ...;
final SVNURL targetUrl = ...;

final SvnCopy copy = svnOperationFactory.createCopy();
copy.addCopySource(SvnCopySource.create(SvnTarget.fromFile(file), SVNRevision.BASE));

You run this code and get

org.tmatesoft.svn.core.SVNException: svn: E200007: Runner for 'org.tmatesoft.svn.core.wc2.SvnCopy' command have not been found; probably not yet implement in this API.
    at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(
    at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(
    at org.tmatesoft.svn.core.wc2.SvnOperationFactory.getImplementation(

I can agree that the stacktrace is a bit cryptic. Actually is tells us that SvnCopy class can perform copy from remote repository to working copy, or from working copy to working copy. To copy to remote repository one should use SvnRemoteCopy class instead:

final SvnRemoteCopy remoteCopy = svnOperationFactory.createRemoteCopy();
remoteCopy.addCopySource(SvnCopySource.create(SvnTarget.fromFile(file), SVNRevision.BASE));

The same is true about other SvnRemoteXXX operations.

Comments are closed.