1

有没有办法在java中将SVN结构作为树结构?

例如:如果我指定路径http://sample.com/repository/pag/branches/dev/Structure/services/

我想要服务下的所有条目,如果它再次包含一个目录,它的条目也在树中?

谢谢。

注意:我见过getDir()。但在这里我必须继续迭代它。

4

1 回答 1

4

如果你需要所有的树,你可以用“状态”请求来做,报告告诉你有一个空的工作副本。一个“状态”请求应该比多个 getDir() 请求快。一个如何用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();
    }
于 2012-07-11T11:56:41.320 回答