How can I get all revisions (not latest) for a special file using SVNkit?
I have used a sample java code to get a file's revision history, but only got one revision. There are many revisions in respository for this file. So how can I get all revisions for this file at o开发者_StackOverflownce?
…
long startRevision = -1;
long endRevision = 0; //HEAD (i.e. the latest) revision
SVNRepositoryFactoryImpl.setup();
repository = SVNRepositoryFactory.create( SVNURL.parseURIEncoded(url) );
ISVNAuthenticationManager authManager =
SVNWCUtil.createDefaultAuthenticationManager( name, password );
repository.setAuthenticationManager( authManager );
Collection logEntries = null;
logEntries = repository.log( new String[] { "EJB.java" }, null, startRevision,
endRevision, true, true );
…
Use 0 for start revision and -1 for end revision
Get the logs and get revisions using those logEntries
SVNRepository repository = null;
repository = SVNRepositoryFactory.create(SVNURL.parseURIDecoded(url));
ISVNAuthenticationManager authManager =
SVNWCUtil.createDefaultAuthenticationManager("", "");
repository.setAuthenticationManager(authManager);
SvnOperationFactory operationFactory = new SvnOperationFactory();
SvnLog logOperation = operationFactory.createLog();
logOperation.setSingleTarget(
SvnTarget.fromURL(
SVNURL.parseURIEncoded(url)));
logOperation.setRevisionRanges( Collections.singleton(
SvnRevisionRange.create(
SVNRevision.create( 1 ),
SVNRevision.HEAD
)
) );
Collection<SVNLogEntry> logEntries = logOperation.run( null );
Now iterate throught the logEntries and use logEntry.getRevision() to get all the revisions till date.
精彩评论