如何获取两个修订日期或编号之间的修订历史记录?

How to Get the revision history between two revision date or number?

这是我之前关于使用 Groovy 脚本从 SVN 存储库获取修订历史记录的问题的重复。我尝试了很多方法,我现在尝试的代码是:

 Calendar cal = Calendar.getInstance();
 cal.set(2015, 01, 14);
 Date date = cal.getTime();

 Calendar cal1 = Calendar.getInstance();
 cal1.set(2014, 10, 12);
 Date date1 = cal1.getTime();

 SVNRevision svr = new SVNRevision(date)
 svr.create(date)
 SVNRevision svr1 = new SVNRevision(date1)
 svr1.create(date1)


 DAVRepositoryFactory.setup();
 String url = "Url"
 String name = "Name";
 String password = "Password";
 SVNRepository repository = null;
 repository = SVNRepositoryFactory.create(SVNURL.parseURIDecoded(url));
 ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(name, password);
  repository.setAuthenticationManager(authManager);
  SVNDirEntry entry = repository.info(".", -1);


 final long EndRevision = repository.getDatedRevision(date)
 final long StartRevision= repository.getDatedRevision(date1)

 println(latestRevision1)
 println(latestRevision2)

 logEntries = repository.log( { "" } as String[] , null ,StartRevision, EndRevision , true , true );


 for ( Iterator entries = logEntries.iterator( ); entries.hasNext( ); ) {
        SVNLogEntry logEntry = ( SVNLogEntry ) entries.next( );
        System.out.println (String.format("revision: %d, date %s", logEntry.getRevision( ), logEntry.getDate()));
 }

但是在执行上面的代码时,错误显示为:

Caught: org.tmatesoft.svn.core.SVNException: Path not found 404 not found

我无法解决这个错误,谁能告诉我错误是什么? 并为我提供解决方案。

您正在用错误的 argument/path 呼叫 respository.log。代码 { "" } as String[] 有效,但未返回您期望的结果。你的意图是这样的:

[""] as String[] // a list of strings (one empty string)

使用上面的代码,您定义了一个闭包({} 仅用于 groovy 中的闭包,而不用于静态数组(如 java 中)),然后您投它到一个字符串列表。结果列表不是空字符串列表,而是闭包的 toString 。参见:

def f = {""} as String[]
print f.inspect()
// => ['c$_run_closure1@3b39132f']

这条路径很可能在您的存储库中不存在。