3

我使用了一个示例 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 );
…
4

2 回答 2

1

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

于 2011-09-18T16:17:39.960 回答
1

使用这些 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() 来获取迄今为止的所有修订。

于 2017-08-17T11:52:48.980 回答