Javaのsubversionライブラリ SVNKitを試す その3

その2はこちら

日付を元にファイルを取得する。

基本的な流れは以下の通り。

  1. SVNRepository.getDatedRevision()を使用して、リビジョンを取得。
  2. SVNRepository.getFile()で1のリビジョンを指定してファイルを取得。


簡単なのでサンプルは省略。

日付範囲を指定してその間にコミットされたファイルの一覧を取得する。

  1. ディレクトリに対して開始日時、終了日時からそれぞれのリビジョン番号をSVNRepository.getDatedRevision()で取得。
  2. SVNRepository.log()を使用して、1.で取得したリビジョン番号から取得。
サンプル
SVNRepository repository = getRepository();
long startRevision = repository.getDatedRevision(startDate);
long endRevision = repository.getDatedRevision(endDate);
if (startRevision != endRevision) { // 等しい場合コミットは無い

	// startRevisionに+1する∵開始日時以降のコミットは次のリビジョンなので。
	repository.log(new String[]{"調べたいディレクトリ"},startRevision+1,endRevision,true,true,new ISVNLogEntryHandler(){
		public void handleLogEntry(SVNLogEntry logEntry) throws SVNException {
			logEntry.getChangedPaths().keySet(); //これがコミットされたファイルのパスである。
		}});
}