简体   繁体   中英

SVN log using SVNKit

I'm sure this question will be silly or annoying on multiple levels....

I am using SVNKit in Java.

I want to get the list of files committed in a particular commit. I have the release ID. Normally I would run something like

svn log url/to/repository -qv -r12345

And I would get the list of commands as normal.

I can't puzzle out how to do a similar thing in SVNKit. Any tips? :)

final SvnOperationFactory svnOperationFactory = new SvnOperationFactory();
final SvnLog log = svnOperationFactory.createLog();
log.setSingleTarget(SvnTarget.fromURL(url));
log.addRange(SvnRevisionRange.create(SVNRevision.create(12345), SVNRevision.create(12345)));
log.setDiscoverChangedPaths(true);
final SVNLogEntry logEntry = log.run();

final Map<String,SVNLogEntryPath> changedPaths = logEntry.getChangedPaths();
for (Map.Entry<String, SVNLogEntryPath> entry : changedPaths.entrySet()) {
    final SVNLogEntryPath svnLogEntryPath = entry.getValue();
    System.out.println(svnLogEntryPath.getType() + " " + svnLogEntryPath.getPath() +
            (svnLogEntryPath.getCopyPath() == null ?
                    "" : (" from " + svnLogEntryPath.getCopyPath() + ":" + svnLogEntryPath.getCopyRevision())));
}

If you want to run one log request for a revision range, you should use log.setReceiver() call with your receiver implemetation.

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