如何在svn日志中搜索

Eme*_*son 6 svn tortoisesvn merge

我希望能够在svn的提交日志中进行搜索.我知道你可以在乌龟身上做到这一点,但是找不到使用命令行的方法.

我们正在采用双层存储库方法,因此稳定分支只能完整地完成和测试故事.为此,我们需要一种方法在提交消息中搜索故事代码(例如:#s1322)并获取要在后续合并命令中使用的修订列表.

例如:searchsvnapp http:// [repo location root]#s1322

结果:4233,4249,4313

Laz*_*ger 8

对于Subversion 1.8,Natural Way(tm)是使用新选项--search+ --search-and来过滤日志

svn log --search #s1322 URL

而且,BTW,每个故事都可以分成自己的分支 - 在这种情况下,根本不需要检测修订范围,你只需要合并分支


the*_*oid 6

这不行吗?

svn log | grep "something"
Run Code Online (Sandbox Code Playgroud)


Eme*_*son 0

我最终使用svnkit开发了自己的工具。

下面是搜索日志的代码的主要部分。我必须使用临时文件夹中的“SVNWCUtil.createDefaultAuthenticationManager”,这样它就不会与我在应该运行该工具的同一个框中的命令行 svn 工具的 svn 配置混淆。如果有足够的兴趣,我可以将整个 webtool 开源。如果您有兴趣,请告诉我(也许对答案进行投票?)。

public Collection<SVNLogEntry> searchSVN(String url, String name,
        String password, long startRevision, long endRevision,
        String searchTerm, String svnUser) throws Exception {
    DAVRepositoryFactory.setup();
    SVNRepository repository = null;
    repository = SVNRepositoryFactory.create(SVNURL.parseURIEncoded(url));
    // changed the config folder to avoid conflicting with anthill svn use
    ISVNAuthenticationManager authManager = SVNWCUtil
            .createDefaultAuthenticationManager(new File("/tmp"), name,
                    password, false);
    repository.setAuthenticationManager(authManager);
    Collection<SVNLogEntry> resultLogEntries = new LinkedList();
    Collection<SVNLogEntry> logEntries = repository.log(
            new String[] { "" }, null, startRevision, endRevision, true,
            true);
    for (SVNLogEntry svnLogEntry : logEntries) {
        if (svnLogEntry.getMessage().indexOf(searchTerm) > -1) {
            if ((svnUser == null || svnUser.equals(""))
                    || svnLogEntry.getAuthor().equals(svnUser)) {
                resultLogEntries.add(svnLogEntry);
            }
        }
    }
    return resultLogEntries;
}
Run Code Online (Sandbox Code Playgroud)