[英]How can I get all revisions (not latest) for a special file using 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 );
…
使用0表示開始修訂版,使用-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()來獲取所有修訂版本,直到日期為止。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.