views:

67

answers:

4

I want to be able to search within the commit logs of svn. I know you can do that on tortoise, 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

+5  A: 

Wouldn't this work?

svn log | grep "something"
the_void
Most of our developers use windows and don't have much unix knowledge. It would be great if it would be a tool that could be used on any platform.
Emerson
You can install Cygwin on Windows, and use grep (among other great 'nix utilities). It's not even that messy of an install; it's self-contained, and you just put it on your path. You'll be glad you made the effort. It can be very useful.
Stephen Harmon
I use [GnuWin utils](http://gnuwin32.sourceforge.net/) for Windows environment, so OS is not an issue here. And piping several simple programs is very powerful concept that you should learn to work effectively.
chalup
I would also advise you to install `Cygwin`, but adding it to the system path may cause problems. If you don't want `Cygwin`, you could install a `svn` command line client (like `SilkSVN`) and use `find` instead of `grep`, as William pointed out.
the_void
+1  A: 

Windows version of the_void's answer:

svn log | find "something"
William Leara
Windows XP says "find" isn't a command...
Emerson
I'm running XP SP3 and it's there for me. Also verified present in Vista and Win7.
William Leara
Seems this way it shows only the log content, without showing the revision number, which is what I really need...
Emerson
A: 

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!

Kieveli
I know that you can do that, but I expected something a bit more straighforward... Anyway, I'm doing a quick webapp using svnkit to search svn for a code and returnthe right command...
Emerson
A: 

Hi, 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 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 resultLogEntries = new LinkedList();

    Collection 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;
  }
Emerson