package com.repositoryclient.svnoptions; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager; import org.tmatesoft.svn.core.internal.io.fs.FSRepositoryFactory; import org.tmatesoft.svn.core.io.ISVNEditor; import org.tmatesoft.svn.core.io.SVNRepository; import org.tmatesoft.svn.core.io.SVNRepositoryFactory; import org.tmatesoft.svn.core.wc.SVNWCUtil; public class StoreManagerFileNodeOption { private String repositoryUrl; private String userName; private String passwd; public StoreManagerFileNodeOption(String userName,String passwd,String repositoryUrl){ this.repositoryUrl=repositoryUrl; } public void addNode(String nodeName){ FSRepositoryFactory.setup(); try { SVNRepository repository=SVNRepositoryFactory.create(SVNURL.parseURIDecoded(repositoryUrl)); ISVNAuthenticationManager authenticationManager = SVNWCUtil .createDefaultAuthenticationManager(userName, passwd); repository.setAuthenticationManager(authenticationManager); ISVNEditor editor=repository.getCommitEditor("logMessage", null,true,null); editor.openRoot(-1); editor.addDir(nodeName, null, -1); editor.closeDir(); editor.closeEdit(); } catch (SVNException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public void renameNode(){ } // public void deleteNode(){ // // } }
其实这里都有说明:http://wiki.svnkit.com/Committing_To_A_Repository