• 利用SVNKit进行版本库的树的导出


    public List searchByTree(String userName,String passwd,String SVNServerUrl,String dirUrl){
            //这里有点像  storeManager的查看功能,但是是从 应用模型的目录开始查看的。
            SVNURL repositoryUrl=null;
            SVNRepository repository=null;
            SVNRepositoryFactoryImpl.setup();
            try {
                repositoryUrl=SVNURL.parseURIEncoded(SVNServerUrl);
                repository=SVNRepositoryFactory.create(repositoryUrl);
                
                ISVNAuthenticationManager authenticationManager=SVNWCUtil.createDefaultAuthenticationManager(userName, passwd);
                repository.setAuthenticationManager(authenticationManager);
                result.clear();
                FileNode rootNode=new FileNode("root", SVNServerUrl, 0, "", 0, null, null);
                listTree(repository, dirUrl,rootNode);
                result.add(rootNode);
            } catch (Exception e) {
                // TODO: handle exception
            }
            return result;
        }
    public void listTree(SVNRepository repository,String dirUrl,FileNode node){
            String currentPath="";
            List list=new ArrayList();
            Collection root;
            try {
                String finalPath[]=dirUrl.split("/");
                for(int i=3;i<finalPath.length;i++){
                    currentPath+=finalPath[i]+"/";
                }
                System.out.println("****************:     "+currentPath);
                root=repository.getDir(currentPath, -1, null, (Collection)null);
                Iterator iterator=root.iterator();
                while (iterator.hasNext()) {
                    SVNDirEntry entry=(SVNDirEntry)iterator.next();
                    if (entry.getKind()==SVNNodeKind.DIR) {
                        FileNode subDirNode=new FileNode(entry.getName(), entry.getURL().toString(),entry.getRevision(),entry.getAuthor(),entry.getSize(), entry.getDate(), null);
                        System.out.println("********"+entry.getURL());
                        listTree(repository, entry.getURL().toString(), subDirNode);
                        list.add(subDirNode);
                    } else {
                        FileNode subnode=new FileNode(entry.getName(), entry.getURL().toString(),entry.getRevision(),entry.getAuthor(),entry.getSize(), entry.getDate(), null);
                        list.add(subnode);
                    }
                    
                }
            } catch (SVNException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            node.setChildren(list);
        }

    以上这段代码,实现了将版本库中的东西组织成List的操作。最后返回的result就是要的list。

    调用的时候这样子:

    ModelDeveloper developer=new ModelDeveloper();
    List ddList=developer.searchByTree("test", "test", "svn://localhost/", "");   //当最后一个参数为“‘时,就是从根目录检索,导出整个结构树。当最后一个参数为"svn://localhost/aa/b"时,就是从版本库的aa/b下的东西导出。
    treeViewer.setInput(ddList);
  • 相关阅读:
    ASP.NET MVC WebAPI 上传图片实例
    PowerDesigner设计权限控制数据模型
    ASP.NET中使用WebService异步加载数据显示到页面
    C#+Dotnetbar海益ERP数据管理系统
    centos 6.X minimal 系列最小化安装完成后,安装mono和jexus过程小记录
    MVC3/4伪静态 jexus mvc伪静态
    petapoco 使用 MiniProfiler Glimpse监控
    尝试整理出自己的开发框架1
    初尝Brnshop移植到Linux Mono Jexus环境运行
    (转)Android开发出来的APP在手机的安装路径是?
  • 原文地址:https://www.cnblogs.com/wangjiyuan/p/tree2.html
Copyright © 2020-2023  润新知