java 获取svn,如何使用Java从SVN获取树结构

该博客介绍了如何在Java中通过SVNKit库获取SVN仓库的结构,以树形方式展示所有服务目录及其子目录的内容。通过一次性执行'status'请求而不是多次调用'getDir()',可以更有效地获取整个目录结构。
摘要由CSDN通过智能技术生成

Is there any way to get the SVN structure as a tree struture in java?

I want what all entries under services and if it again contains a directory its enteries also in a tree?

Thanks.

Note : i have seen the getDir(). But here i have to keep on iterating it.

解决方案

If you need all the tree, you may do that with "status" request with report telling that you have an empty working copy. One "status" request should be faster than a number of getDir() requests. An example how to do that with SVNKit

final SVNRepository svnRepository = SVNRepositoryFactory.create(url);

try {

svnRepository.status(revision, "", SVNDepth.INFINITY, new ISVNReporterBaton() {

@Override

public void report(ISVNReporter reporter) throws SVNException {

reporter.setPath("", null, revision, SVNDepth.INFINITY, true);

reporter.finishReport();

}

}, new ISVNEditor() {

@Override

public void targetRevision(long revision) throws SVNException {

}

@Override

public void openRoot(long revision) throws SVNException {

System.out.println("");

}

@Override

public void deleteEntry(String path, long revision) throws SVNException {

}

@Override

public void absentDir(String path) throws SVNException {

}

@Override

public void absentFile(String path) throws SVNException {

}

@Override

public void addDir(String path, String copyFromPath, long copyFromRevision) throws SVNException {

System.out.println("directory: " + path);

}

@Override

public void openDir(String path, long revision) throws SVNException {

}

@Override

public void changeDirProperty(String name, SVNPropertyValue value) throws SVNException {

}

@Override

public void closeDir() throws SVNException {

}

@Override

public void addFile(String path, String copyFromPath, long copyFromRevision) throws SVNException {

System.out.println("file: " + path);

}

@Override

public void openFile(String path, long revision) throws SVNException {

}

@Override

public void changeFileProperty(String path, String propertyName, SVNPropertyValue propertyValue) throws SVNException {

}

@Override

public void closeFile(String path, String textChecksum) throws SVNException {

}

@Override

public SVNCommitInfo closeEdit() throws SVNException {

return null;

}

@Override

public void abortEdit() throws SVNException {

}

@Override

public void applyTextDelta(String path, String baseChecksum) throws SVNException {

}

@Override

public OutputStream textDeltaChunk(String path, SVNDiffWindow diffWindow) throws SVNException {

return null;

}

@Override

public void textDeltaEnd(String path) throws SVNException {

}

});

} finally {

svnRepository.closeSession();

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值