SVNRepository.getStatus() vs. SVNRepository.getDir()
Here we will show how you can fetch properties from the repository recursively in a single request using SVNRepository. Many newbie users who come across the SVNRepository interface for the first time, decide to implement the task of recursive retrieving properties from a repository tree with the help of SVNRepository's getDir() method. To get properties recursively you'll have to call getDir() in recursion. It's not a wrong way, but consider the repository tree with multiple leaves (with hundreds or maybe thousands of them). For each directory leave getDir() sends a new request what leads to extremely slow performance.
Basically, what you do with getDir() is the following:
1 public void fetchPropsFromRepository(SVNRepository repos, String path, long revision,
2 Map pathsToProps) throws SVNException {
3 SVNProperties props = new SVNProperties();
4 Collection children = repos.getDir(path, revision, props, SVNDirEntry.DIRENT_ALL, null);
5 pathsToProps.put(path, props);
6 for (Iterator childrenIter = children.iterator(); childrenIter.hasNext();) {
7 SVNDirEntry childEntry = (SVNDirEntry) childrenIter.next();
8 if (childEntry.getKind() == SVNNodeKind.DIR) {
9 String childName = childEntry.getName();
10 String childPath = !"".equals(path) && !path.endsWith("/") ?
11 path + "/" + childName : path + childName;
12 fetchPropsFromRepository(repos, childPath, revision, pathsToProps);
13 }
14 }
15 }