简体   繁体   English

如何在Java中仅从SVN存储库中检出目录

[英]How can i checkout only directory from SVN repositry in java

I am new to SVN. 我是SVN的新手。 I want to checkout all directories under the source folder of SVN repositry to my local, using java code. 我想使用Java代码将SVN存储库的源文件夹下的所有目录检出到本地。

I am using the below code but it is exporting both files and directories while I only want to copy the directories. 我正在使用下面的代码,但它只导出目录时导出文件和目录。

SVNClientManager ourClientManager = SVNClientManager.newInstance(null, authManager);
SVNUpdateClient updateClient = ourClientManager.getUpdateClient();
updateClient.setIgnoreExternals(false);
updateClient.doExport(url1, checkoutPath1, SVNRevision.create(111111), SVNRevision.create(111111),null,true,SVNDepth.INFINITY);

There is no direct command to detch the dir from SVN. 没有直接命令从SVN提取目录。 You can you some code like below. 您可以像下面这样一些代码。

private List<String> dirCheckout(SvnOperationFactory svnOperationFactory) throws SVNException {
    SVNRepository repository = SVNRepositoryFactory.create(SVNURL.parseURIEncoded(URL),null);
    repository.setAuthenticationManager(svnOperationFactory.getAuthenticationManager());
    Collection<SVNDirEntry> entries = (Collection<SVNDirEntry>) repository.getDir("", (Your Object).getRevision(), null,(Collection<?>) null);    
    Iterator<SVNDirEntry> iterator =entries.iterator();
    List<String> list = new ArrayList<String>();
    while(iterator.hasNext()){
        SVNDirEntry entry =(SVNDirEntry) iterator.next();
            if(entry.getKind()==SVNNodeKind.DIR)
                list.add(entry.getName());
        }
    return list;
}

Nohow. 没事

It isn't possible (in single command) with existing --depth options in pure Subversion, I'm sure, SVNKit can't give more options than backend 我敢肯定,纯Subversion中现有的--depth选项不可能(用单个命令),SVNKit不能提供比后端更多的选项

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM