2011-09-02 213 views
3

我已經使用了一個示例java代碼來獲取文件的修訂歷史記錄,但只有一個修訂版本。 這個文件的版本庫有很多修訂。那麼我怎樣才能一次獲得這個文件的所有修訂?如何使用SVNkit獲取特殊文件的所有修訂版本(最新版本)?

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

回答

1

的開始版本使用0和-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); 

現在迭代throught的logEntries和使用logEntry.getRevision得到修訂()以獲得所有的修改日期。

相關問題