如何使用SVNKit获取从一个分支合并到另一个分支的所有修订的列表?

时间:2017-01-06 16:34:01

标签: java svn svnkit

目的:

作为质量检查,我们需要确保所有合格的修订都合并到所有更高版本。

实施例

Release_10 --> Release_11

在TortoiseSVN中,通过单击"显示日志"可以很容易地找出已合并的修订版本。按钮。通过格式化和合并图标可以清楚地区分合并的修订。

您还可以通过纯SVN列出所有合并的修订:

C:\Release_11>svn mergeinfo --show-revs merged https://svn_repo/project/branches/releases/Release_10
r32894
r32897
r32901
r32903
r32929
r32987
r32994
r32996
r33006
r33017
r33020
r33021
r33041
r33045
r33077

目前,我有代码列出了所有修订信息:

SVNURL svnURL = SVNURL.parseURIEncoded(url);
SVNRepository repository = SVNRepositoryFactory.create(svnURL);
BasicAuthenticationManager authManager = BasicAuthenticationManager.newInstance("username", "password".toCharArray());
authManager.setProxy("00.00.00.00", 8080, null, (char[])null);
repository.setAuthenticationManager(authManager);
@SuppressWarnings("unchecked")
Collection<SVNLogEntry> logEntries = repository.log(new String[] { "" }, null, 0, -1, true, true);

现在我只需要确定哪些已合并。

设定:

  1. 单次调用repo以获取所有合并的修订版。 (或者更好的是:一次调用以获得所有修订以及它们是否合并。)
  2. 不希望本地结帐SVN回购。
  3. 注意:

    • 使用SVNKIT v1.8.14,但未锁定特定版本。

1 个答案:

答案 0 :(得分:2)

如果您使用源和目标的绝对网址运行svn mergeinfo,则您不需要本地检查存储库:

svn mergeinfo --show-revs merged https://svn_repo/project/branches/releases/Release_10 https://svn_repo/project/branches/releases/Release_11

要在SVNKit 1.7或更高版本上运行此命令,您可以使用SvnLogMergeInfo

SvnOperationFactory svnOperationFactory = new SvnOperationFactory();
try {
    String repo = "https://svn_repo/project/branches/releases/";
    String srcBranch = repo + "Release_10";
    String dstBranch = repo + "Release_11";

    // svnOperationFactory.setAuthenticationManager(null);

    SvnLogMergeInfo op = svnOperationFactory.createLogMergeInfo();
    op.setFindMerged(true); // --show-revs merged
    op.setSource(SvnTarget.fromURL(SVNURL.parseURIEncoded(srcBranch)));
    op.setSingleTarget(SvnTarget.fromURL(SVNURL.parseURIEncoded(dstBranch)));
    op.setReceiver(new ISvnObjectReceiver<SVNLogEntry>() {

        @Override
        public void receive(SvnTarget target, SVNLogEntry logEntry) throws SVNException {
            System.out.println("------\n" + logEntry);
        }

    });
    op.run();
} finally {
    svnOperationFactory.dispose();
}

对于旧版本,您可以使用SVNDiffClient.doGetLogMergedMergeInfo