SVNKIT的SVNCommitClient的doMkDir的操作

package com.repositoryclient.svnoptions;

import java.io.File;

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.internal.io.svn.SVNRepositoryFactoryImpl;
import org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions;
import org.tmatesoft.svn.core.wc.ISVNOptions;
import org.tmatesoft.svn.core.wc.SVNClientManager;
import org.tmatesoft.svn.core.wc.SVNCommitClient;
import org.tmatesoft.svn.core.wc.SVNWCUtil;

public class ModelDeveloperUpLoadOption{
    public  boolean doUpLoad(String userName,String passwd,String SVNServerUrl,String dirPath,String folderName){
        SVNClientManager ourClientManager;
        // 初始化支持svn://协议的库
        SVNRepositoryFactoryImpl.setup();
        // 相关变量赋值
        SVNURL repositoryUrl = null;
        SVNURL uploadFolderUrl=null;
        SVNURL[] folder=new SVNURL[1];
        try {
            repositoryUrl = SVNURL.parseURIEncoded(SVNServerUrl);
            uploadFolderUrl=SVNURL.parseURIEncoded(SVNServerUrl+folderName);
            ISVNOptions options = SVNWCUtil.createDefaultOptions(true);
            // 实例化客户端管理类
            ourClientManager = SVNClientManager.newInstance(
                    (DefaultSVNOptions) options, userName, passwd);
            // 要把此目录的内容导入到版本库
            File impDir = new File(dirPath);
            // 执行导入操作
            SVNCommitClient svnCommitClient = ourClientManager.getCommitClient();
            
            folder[0]=uploadFolderUrl;
            svnCommitClient.doMkDir(folder, folderName);
            SVNCommitInfo commitInfo = svnCommitClient.doImport(impDir,
                    uploadFolderUrl, "import operation!", null, true, true,
                    SVNDepth.INFINITY);
            //System.out.println(commitInfo.toString());
            return true;
        } catch (SVNException e) {
            // TODO: handle exception
            e.printStackTrace();
            return false;
        }
    }

}

注意,这个函数的第一个参数要包含新建的文件夹的名称,就是说给出的url一定是一个新的url。第二个参数可能是message之类的意思。

猜你喜欢

转载自wjy320.iteye.com/blog/1999856