简体   繁体   中英

How to get SVNKit log between two dates?

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.

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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