如何使用SVNkit获取特殊文件的所有修订(不是最新版本)?

时间:2011-09-02 06:53:38

标签: java svn svnkit

我使用了一个示例java代码来获取文件的修订历史记录,但只获得了一个修订版。 存储库中有许多针对此文件的修订。那么如何立即获得该文件的所有修订版?

…
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 );
…

2 个答案:

答案 0 :(得分:1)

使用0表示开始修订,使用-1表示结束修订

答案 1 :(得分:0)

使用这些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 );

现在遍历logEntries并使用logEntry.getRevision()获取所有修订版本直到日期。

相关问题