Question

I am trying to get the log from a SVN repo using SVNKit.

public static void svnLogTest() {
    final SvnOperationFactory svnOperationFactory = new SvnOperationFactory();
    final SvnLog log = svnOperationFactory.createLog();
    SVNURL url = null;
    try {
        url = SVNURL
                .parseURIEncoded("https://svn-repo");
    } catch (SVNException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    log.setSingleTarget(SvnTarget.fromURL(url));
    log.addRange(SvnRevisionRange.create(SVNRevision.create(111),
            SVNRevision.create(222)));
    log.getRevisionRanges();
    SVNLogEntry logEntry = null;
    try {
        logEntry  = log.run();
        System.out.println(logEntry.getAuthor() + " " + logEntry.getRevision() + " " 
                + logEntry.getDate());

    } catch (SVNException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

But it will give me only the first revision, How should I iterate to print the log for a particular date range ?

Était-ce utile?

La solution

This is because

log.run();

always returns only one log entry (the same is true for other SvnOperation#run methods). To get all entries use receiver:

    log.setReceiver(new ISvnObjectReceiver<SVNLogEntry>() {
        @Override
        public void receive(SvnTarget target, SVNLogEntry logEntry) throws SVNException {
            //process logEntry here
        }
    });
    log.run();
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top