简体   繁体   English

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

[英]How to get tree structure from SVN using java

Is there any way to get the SVN structure as a tree struture in java? 有没有办法在SV中将SVN结构作为树结构?

For Eg: if i specify a path http://sample.com/repository/pag/branches/dev/Structure/services/ 例如:如果我指定路径http://sample.com/repository/pag/branches/dev/Structure/services/

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() . 注意 :我见过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. 一个“状态”请求应该比一些getDir()请求更快。 An example how to do that with SVNKit 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("<root>");
            }

            @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();
    }

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

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