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 t
I was looking for the same thing and found this:
http://svn-search.sourceforge.net/
I wrote this as a cygwin bash script to solve this problem.
However it requires that the search term is currently within the filesystem file. For all the files that match the filesystem grep, an grep of all the svn diffs for that file are then performed. Not perfect, but should be good enough for most usage. Hope this helps.
/usr/local/bin/svngrep
#!/bin/bash
# Usage: svngrep $regex @grep_args
regex="$@"
pattern=`echo $regex | perl -p -e 's/--?\S+//g; s/^\\s+//;'` # strip --args
if [[ ! $regex ]]; then
echo "Usage: svngrep \$regex @grep_args"
else
for file in `grep -irl --no-messages --exclude=\*.tmp --exclude=\.svn $regex ./`; do
revs="`svnrevisions $file`";
for rev in $revs; do
diff=`svn diff $file -r$[rev-1]:$rev \
--diff-cmd /usr/bin/diff -x "-Ew -U5 --strip-trailing-cr" 2> /dev/null`
context=`echo "$diff" \
| grep -i --color=none -U5 "^\(+\|-\).*$pattern" \
| grep -i --color=always -U5 $pattern \
| grep -v '^+++\|^---\|^===\|^Index: ' \
`
if [[ $context ]]; then
info=`echo "$diff" | grep '^+++\|^---'`
log=`svn log $file -r$rev`
#author=`svn info -r$rev | awk '/Last Changed Author:/ { print $4 }'`;
echo "========================================================================"
echo "========================================================================"
echo "$log"
echo "$info"
echo "$context"
echo
fi;
done;
done;
fi
/usr/local/bin/svnrevisions
#!/bin/sh
# Usage: svnrevisions $file
# Output: list of fully numeric svn revisions (without the r), one per line
file="$@"
svn log "$file" 2> /dev/null | awk '/^r[[:digit:]]+ \|/ { sub(/^r/,"",$1); print $1 }'
I came across this bash script, but I have not tried it.
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.
I usually do what Jack M says (use svn log --verbose) but I pipe to grep instead of less.
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/