开发者

How do I search within svn logs

I want to be able to search within the commit logs of svn. I know you can do that on tortoise,开发者_如何学Go but couldn't find a way using the command line.

We are moving to a two-tiered repository approach, so that the stable branch will only get stories fully completed and tested. To achieve that, we would need a way to search within the commit messages for the story code (eg:#s1322) and get a list of the revisions to be used in a subsequent merge command.

Ex: searchsvnapp http://[repo location root] #s1322

result: 4233,4249,4313


For Subversion 1.8 The Natural Way (tm) is to use new options --search + --search-and for filtering logs

svn log --search #s1322 URL

And, BTW, each story can be separated into own branch - in this case detection of revision-range is not needed at all and you just merge branch


Wouldn't this work?

svn log | grep "something"


Windows version of the_void's answer:

svn log | find "something"


First, make sure you have the Subversion command line (collabnet is the distro I use) that matches your Tortoise 'Subversion' release. Check in the Tortoise about box to find the Subversion revision. Each subversion tool has its own copy of the Subversion client, and they're not always interchangeable. Major releases will break the compatibility.

From the command line:

svn log > svn.out

Then pop it up in your favourite editor!


I ended up developing my own tool, using svnkit.

Further below is the main bit of the code that searches on the logs. I had to use the "SVNWCUtil.createDefaultAuthenticationManager" using a temporary folder so that it wouldn't mess with the svn configuration of a cmd line svn tool that I have in the same box that should run the tool. If there is enough interest I can make the whole webtool opensource. Please let me know (voting on the answer maybe?) if you are interested.

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;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜