【问题标题】:How to get SVNKit log between two dates?如何在两个日期之间获取 SVNKit 日志?
【发布时间】:2017-11-14 05:46:21
【问题描述】:

我正在使用 SVNKit 1.7,我想获取两个日期之间条目的历史日志。我发现的所有文档都只显示了检索两个修订号之间的条目。

我基本上是想运行以下命令

svn log -v --xml --non-interactive --no-auth-cache http://foo.com  --username myusername --password mypassword -r {""2012-10-02""}:{""2012-11-01""}

现在我正在通过命令行在 Java 中使用运行时类调用它。

我使用此信息的目的是按 SVN 活动的月份生成指标。

如果我必须使用修订号,有没有办法根据日期找到最接近的修订号?

感谢您的帮助。

【问题讨论】:

    标签: java svnkit


    【解决方案1】:

    谢谢 Dmitry,您的回答很有帮助,但我最终使用了 org.tmatesoft.svn.core.io.SVNRepository 类和该类的 getDatedRevision() 方法。我在看文档的时候看了很多遍这个方法。

    【讨论】:

      【解决方案2】:
          final SvnOperationFactory svnOperationFactory = new SvnOperationFactory();
          try {
              final SVNURL url = ...;
      
              svnOperationFactory.setAuthenticationManager(new BasicAuthenticationManager("myusername", "mypassword"));
      
              final SvnLog log = svnOperationFactory.createLog();
              log.addRange(SvnRevisionRange.create(SVNRevision.create(date1), SVNRevision.create(date2)));
              log.setDiscoverChangedPaths(true);
              log.setSingleTarget(SvnTarget.fromURL(url));
              log.setReceiver(new ISvnObjectReceiver<SVNLogEntry>() {
                  @Override
                  public void receive(SvnTarget target, SVNLogEntry logEntry) throws SVNException {
                      ...
                  }
              });
              log.run();
          } finally {
              svnOperationFactory.dispose();
          }
      

      【讨论】:

      • 我最终在该类上使用了 SVNRepository 存储库和 getDatedRevision() 方法来获取在指定日期之前或之前的最新版本号。
      猜你喜欢
      • 2018-06-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-11
      • 1970-01-01
      • 2020-03-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多