Reputation: 754
I am using SVNKit 1.7 and I am wanting to get a history log of entries between two dates. All the documentation that I found only shows retrieving entries between two revision numbers.
I basically want to run the following command
svn log -v --xml --non-interactive --no-auth-cache http://foo.com --username myusername --password mypassword -r {""2012-10-02""}:{""2012-11-01""}
Right now I'm doing this via a command line calling it in Java with the Runtime classes.
What I am using this info for is to generate metrics by month of SVN activity.
If I have to use revision numbers, is there a way to find the nearest revision # based on a date?
Thanks for your help.
Upvotes: 2
Views: 3247
Reputation: 754
Thank you Dmitry your answer was quite helpful, but I ended up using the org.tmatesoft.svn.core.io.SVNRepository class and the getDatedRevision() method of the class. I glanced over this method many times while looking at the docs.
Upvotes: 6
Reputation: 8968
final SvnOperationFactory svnOperationFactory = new SvnOperationFactory();
try {
final SVNURL url = ...;
svnOperationFactory.setAuthenticationManager(new BasicAuthenticationManager("myusername", "mypassword"));
final SvnLog log = svnOperationFactory.createLog();
log.addRange(SvnRevisionRange.create(SVNRevision.create(date1), SVNRevision.create(date2)));
log.setDiscoverChangedPaths(true);
log.setSingleTarget(SvnTarget.fromURL(url));
log.setReceiver(new ISvnObjectReceiver<SVNLogEntry>() {
@Override
public void receive(SvnTarget target, SVNLogEntry logEntry) throws SVNException {
...
}
});
log.run();
} finally {
svnOperationFactory.dispose();
}
Upvotes: 5