王吉元-NWPU

导航

 
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

posted on 2013-10-24 16:00  王吉元  阅读(440)  评论(0编辑  收藏  举报