svnkitの「jar」ファイルが必要になります。「jar」ファイルをダウンロードし、クラスパスを設定してください。
http://svnkit.com/index.html
import java.io.File; import java.util.Collections; import org.tmatesoft.svn.core.SVNCommitInfo; import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.SVNClientManager; import org.tmatesoft.svn.core.wc.SVNCopySource; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc.SVNRevisionRange; import org.tmatesoft.svn.core.wc.SVNWCUtil;
SVNClientManager manager = SVNClientManager.newInstance( SVNWCUtil.createDefaultOptions(true), "ユーザID", "パスワード" );
long revisionNumber = manager.getUpdateClient().doCheckout(
SVNURL.parseURIDecoded("チェックアウト対象のリポジトリURL"),
new File("チェックアウト先ディレクトリ"),
SVNRevision.HEAD,
SVNRevision.HEAD,
true
);
System.out.println(revisionNumber);
SVNCommitInfo copyInfo = manager.getCopyClient().doCopy(
new SVNCopySource[]{
new SVNCopySource(
SVNRevision.UNDEFINED,
SVNRevision.HEAD,
SVNURL.parseURIDecoded("コピー元リポジトリURL")
)
},
SVNURL.parseURIDecoded("コピー先リポジトリURL"),
false,
false,
true,
"コメント内容",
null
);
System.out.println(copyInfo);
manager.getDiffClient().doMerge(
SVNURL.parseURIDecoded("マージ元リポジトリURL"),
SVNRevision.HEAD,
Collections.singleton(
new SVNRevisionRange(
SVNRevision.create(開始リビジョン),
SVNRevision.create(終了リビジョン)
)
),
new File("マージ先ディレクトリ"),
SVNDepth.INFINITY,
true,
false,
false,
false
);
manager.getCommitClient().doCommit(
new File[]{new File("コミット対象のディレクトリ")},
false,
"コメント内容",
false,
true
);