如何使用SVNKit获取从一个分支合并到另一个分支的所有修订的列表? [英] How to use SVNKit to get the list of all revisions merged from one branch to another?
问题描述
作为质量检查,我们需要确保所有合格的修订都合并到所有更高版本。
As a quality check, we need to make sure that all qualified revisions are merged up to all higher revisions.
Release_10 - > Release_11
在TortoiseSVN中,通过单击显示日志按钮可以很容易地找出合并的修订版本。通过格式化和合并图标可以清楚地区分合并的修订。
In TortoiseSVN, it is very easy to figure out which revisions have been merged by clicking the "Show Log" button. Merged revisions are clearly distinguished by formatting and a merge icon.
您还可以通过纯SVN列出所有合并的修订:
You can also list all merged revisions through pure 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
目前,我有代码列出所有修订信息:
Currently, I have the code that lists all revision info:
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);
现在我只需要确定哪些已经合并。
Now I just need to figure out which ones have been merged.
- 单次调用repo以获取所有合并的修订版。 (或者更好的是:一次调用以获得所有修订以及它们是否合并。)
- 不希望本地结账SVN回购。
注意:
- 使用SVNKIT v1.8.14,但我没有被锁定到特定的版本。
推荐答案
如果你运行 svn mergeinfo
使用源和目标的绝对URL,您不需要本地检查存储库:
If you run svn mergeinfo
with absolute URLs for both source and target, you won't need a local checkout of the repository:
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
:
To run this command, on SVNKit 1.7 or later, you can use 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
。
For older versions, you can use SVNDiffClient.doGetLogMergedMergeInfo
.
这篇关于如何使用SVNKit获取从一个分支合并到另一个分支的所有修订的列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!