zoukankan      html  css  js  c++  java
  • 利用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);
  • 相关阅读:
    来电科技-自助租借充电宝
    一次使用NodeJS实现网页爬虫记
    八爪鱼采集器
    杭州市职称系统
    zz
    有道智选-网易效果推广
    Ubuntu10.04下载并编译Android4.3源代码
    poj 1654 Area 多边形面积
    Android利用Looper在子线程中改变UI
    Notepad 快捷键 大全
  • 原文地址:https://www.cnblogs.com/wangjiyuan/p/tree2.html
Copyright © 2011-2022 走看看