The other day I was looking for a piece of software that could help me pull data out of SVN repository so I can do a little analysis on it. Browsing over the net, I run into several tools, but the one that finally caught my eye was SNVKit. The package does a lot of stuff, but for instance, if you are only interested on pulling information out, it makes your like quite easy. The code below is just a simple example of how you can use it to pull information out of a SVN repository.
import java.util.LinkedList;
import org.tmatesoft.svn.core.ISVNDirEntryHandler;
import org.tmatesoft.svn.core.SVNDirEntry;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl;
import org.tmatesoft.svn.core.internal.wc.admin.SVNEntry;
import org.tmatesoft.svn.core.wc.SVNClientManager;
import org.tmatesoft.svn.core.wc.SVNLogClient;
import org.tmatesoft.svn.core.wc.SVNRevision;
import org.tmatesoft.svn.core.SVNNodeKind;
public class SVNReader {
public static void main ( String [] sArgs ) throws SVNException {
final LinkedList<SVNDirEntry> lstFiles = new LinkedList<SVNDirEntry>();
SVNRepositoryFactoryImpl.setup();
SVNClientManager clientManager = SVNClientManager.newInstance();
SVNLogClient lc = clientManager.getLogClient();
SVNURL svnUrl = SVNURL.parseURIDecoded(
"svn://some.server.com:3690/path/to/trunk"
);
lc.doList(svnUrl, SVNRevision.HEAD, SVNRevision.HEAD, false, true, new ISVNDirEntryHandler() {
public void handleDirEntry(SVNDirEntry svnEntry) throws SVNException {
if ( svnEntry.getKind()==SVNNodeKind.FILE) {
lstFiles.add(svnEntry);
}
}
});
for ( SVNDirEntry svnEntry:lstFiles ) {
System.out.println(svnEntry);
}
}
}