views:

2699

answers:

10

Is there a way to perform a full text search of a subversion repository, including all the history?

For example, I've written a feature that I used somewhere, but then it wasn't needed, so I svn rm'd the files, but now I need to find it again to use it for something else. The svn log probably says something like "removed unused stuff", and there's loads of checkins like that.

+2  A: 

I don't have any experience with it, but SupoSE (open source, written in Java) is a tool designed to do exactly this.

dF
+6  A: 

I have been looking for something similar. The best I have come up with is OpenGrok. I have not tried to implement it yet, but sounds promising.

Mike Schall
I've been using OpenGrok for several months, it rocks.
Mauricio Scheffer
+1  A: 

The best way that I've found to do this is with less:

svn log --verbose | less

Once less comes up with output, you can hit / to search, like VIM.

Edit:

According to the author, he wants to search more than just the messages and the file names. In which case you will be required to ghetto-hack it together with something like:

svn diff -r0:HEAD | less

You can also substitute grep or something else to do the searching for you. If you want to use this on a sub-directory of the repository, you will need to use svn log to discern the first revision in which that directory existed, and use that revision instead of 0.

Jack M.
That's not full text searching, it's searching the logs and filenames.
rjmunro
If that is the case, then you need to use more expressive commit logs. If you want to grep the difference between revisions, that is whole other ball of wax. And I personally do not know a way to do that.
Jack M.
+1  A: 

I usually do what Jack M says (use svn log --verbose) but I pipe to grep instead of less.

Mark Biek
That's not full text searching, it's searching the logs and filenames.
rjmunro
That is what I usually end up doing, but I've found that with `less` you can actually see the revision, date, etc instead of just the line in the comment. That is usually what I'm looking for anyway.
Jack M.
+3  A: 

I was looking for the same thing and found this:

http://svn-search.sourceforge.net/

+7  A: 

If you are running Windows have a look at SvnQuery. It maintains a full text index of local or remote repositories. Every document ever committed to a repository gets indexed. You can do google-like queries from a simple web interface.

Christian Rodemeyer
+5  A: 

I'm using a small shellscript, but this only works for a single file. You can ofcourse combine this with find to include more files.

#!/bin/bash
for REV in `svn log $1 | grep ^r[0-9] | awk '{print $1}'`; do 
  svn cat $1 -r $REV | grep -q $2
  if [ $? -eq 0 ]; then 
    echo "$REV"
  fi 
done

If you really want to search everything, use the svnadmin dump command and grep through that.

Bas Grolleman
+1 for the admin dump pointer.
Adrian
A: 

While not free, you might take a look at Fisheye from Atlassian, the same folks that bring you JIRA. It does full text search against SVN with many other useful features.

http://www.atlassian.com/software/fisheye/

A: 

I just ran into this problem and

svnadmin dump <repo location> |grep -i <search term>

did the job for me. Returned the revision of the first occurrence and quoted the line I was looking for.

Peter
+3  A: 

git svn clone

git grep < some regex >

luis gutierrez
Good point. The gitk GUI does this kind of search very well, and it's easy to use the git svn tools to access an svn repository. Admitedly, I've moved entirely to using git since the time I asked this question, so accepting this answer might be a bit specific to me.
rjmunro