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

<p>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.</p>

<p><strong>Edit 2016-04-15:</strong> Please note that what is asked here by the term "full text search", is to <strong>search the actual diffs of the commit history, and not filenames and/or commit messages</strong>. I'm pointing this out because the author's phrasing above does not reflect that very well - since in his example he might as well be only looking for a filename and/or commit message. Hence a lot of the <code>svn log</code> answers and comments.</p>

[{'answer_id': 44185, 'author': 'dF.', 'author_id': 3002, 'author_profile': 'https://Stackoverflow.com/users/3002', 'pm_score': 2, 'selected': False, 'text': '<p>I don\'t have any experience with it, but <a href="http://supose.soebes.de/" rel="nofollow noreferrer">SupoSE</a> (open source, written in Java) is a tool designed to do exactly this.</p>\n'}, {'answer_id': 44193, 'author': 'Mike Schall', 'author_id': 4231, 'author_profile': 'https://Stackoverflow.com/users/4231', 'pm_score': 3, 'selected': False, 'text': '<p>I have been looking for something similar.  The best I have come up with is <a href="http://opengrok.github.io/OpenGrok/" rel="nofollow noreferrer" title="OpenGrok">OpenGrok</a>.  I have not tried to implement it yet, but sounds promising.</p>\n'}, {'answer_id': 44226, 'author': 'Jack M.', 'author_id': 3421, 'author_profile': 'https://Stackoverflow.com/users/3421', 'pm_score': 4, 'selected': False, 'text': "<p>The best way that I've found to do this is with less:</p>\n\n<blockquote>\n  <p>svn log --verbose | less</p>\n</blockquote>\n\n<p>Once less comes up with output, you can hit <code>/</code> to search, like VIM.</p>\n\n<p><strong>Edit:</strong></p>\n\n<p>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:</p>\n\n<pre><code>svn diff -r0:HEAD | less\n</code></pre>\n\n<p>You can also substitute <code>grep</code> 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 <code>svn log</code> to discern the first revision in which that directory existed, and use that revision instead of <code>0</code>.</p>\n"}, {'answer_id': 44234, 'author': 'Mark Biek', 'author_id': 305, 'author_profile': 'https://Stackoverflow.com/users/305', 'pm_score': 1, 'selected': False, 'text': '<p>I usually do what <a href="https://stackoverflow.com/questions/44176/searching-subversion-history-full-text#44226">Jack M</a> says (use svn log --verbose) but I pipe to <strong>grep</strong> instead of less.</p>\n'}, {'answer_id': 238130, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 2, 'selected': False, 'text': '<p>I was looking for the same thing and found this:</p>\n\n<p><a href="http://svn-search.sourceforge.net/" rel="nofollow noreferrer">http://svn-search.sourceforge.net/</a></p>\n'}, {'answer_id': 485763, 'author': 'Christian Rodemeyer', 'author_id': 58985, 'author_profile': 'https://Stackoverflow.com/users/58985', 'pm_score': 5, 'selected': False, 'text': '<p>If you are running Windows have a look at <a href="http://svnquery.tigris.org" rel="noreferrer">SvnQuery</a>. 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.</p>\n'}, {'answer_id': 2019277, 'author': 'Bas Grolleman', 'author_id': 245387, 'author_profile': 'https://Stackoverflow.com/users/245387', 'pm_score': 4, 'selected': False, 'text': '<p>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.</p>\n\n<pre><code>#!/bin/bash\nfor REV in `svn log $1 | grep ^r[0-9] | awk \'{print $1}\'`; do \n  svn cat $1 -r $REV | grep -q $2\n  if [ $? -eq 0 ]; then \n    echo "$REV"\n  fi \ndone\n</code></pre>\n\n<p>If you really want to search everything, use the <code>svnadmin dump</code> command and grep through that. </p>\n'}, {'answer_id': 2714757, 'author': 'mrjabba', 'author_id': 326139, 'author_profile': 'https://Stackoverflow.com/users/326139', 'pm_score': 3, 'selected': False, 'text': '<p>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.</p>\n\n<p><a href="http://www.atlassian.com/software/fisheye/" rel="noreferrer">http://www.atlassian.com/software/fisheye/</a></p>\n'}, {'answer_id': 3110880, 'author': 'pfyon', 'author_id': 136746, 'author_profile': 'https://Stackoverflow.com/users/136746', 'pm_score': 3, 'selected': False, 'text': '<p>I just ran into this problem and</p>\n\n<pre><code>svnadmin dump &lt;repo location&gt; |grep -i &lt;search term&gt;\n</code></pre>\n\n<p>did the job for me. Returned the revision of the first occurrence and quoted the line I was looking for.</p>\n'}, {'answer_id': 3820708, 'author': 'luis gutierrez', 'author_id': 461606, 'author_profile': 'https://Stackoverflow.com/users/461606', 'pm_score': 7, 'selected': True, 'text': '<pre><code>git svn clone &lt;svn url&gt;\n</code></pre>\n\n\n\n<pre><code>git log -G&lt;some regex&gt;\n</code></pre>\n'}, {'answer_id': 8766101, 'author': 'James McGuigan', 'author_id': 748503, 'author_profile': 'https://Stackoverflow.com/users/748503', 'pm_score': 1, 'selected': False, 'text': '<p>I wrote this as a cygwin bash script to solve this problem.</p>\n\n<p>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.</p>\n\n<p><strong>/usr/local/bin/svngrep</strong></p>\n\n<pre><code>#!/bin/bash\n# Usage: svngrep $regex @grep_args\n\nregex="$@"\npattern=`echo $regex | perl -p -e \'s/--?\\S+//g; s/^\\\\s+//;\'` # strip --args\nif [[ ! $regex ]]; then\n    echo "Usage: svngrep \\$regex @grep_args"\nelse \n    for file in `grep -irl --no-messages --exclude=\\*.tmp --exclude=\\.svn $regex ./`;     do \n        revs="`svnrevisions $file`";\n        for rev in $revs; do\n            diff=`svn diff $file -r$[rev-1]:$rev \\\n                 --diff-cmd /usr/bin/diff -x "-Ew -U5 --strip-trailing-cr" 2&gt; /dev/null`\n            context=`echo "$diff" \\\n                 | grep -i --color=none   -U5 "^\\(+\\|-\\).*$pattern" \\\n                 | grep -i --color=always -U5             $pattern  \\\n                 | grep -v \'^+++\\|^---\\|^===\\|^Index: \' \\\n                 `\n            if [[ $context ]]; then\n                info=`echo "$diff" | grep \'^+++\\|^---\'`\n                log=`svn log $file -r$rev`\n                #author=`svn info -r$rev | awk \'/Last Changed Author:/ { print $4 }\'`; \n\n                echo "========================================================================"\n                echo "========================================================================"\n                echo "$log"\n                echo "$info"\n                echo "$context"\n                echo\n            fi;\n        done;\n    done;\nfi\n</code></pre>\n\n<p><strong>/usr/local/bin/svnrevisions</strong></p>\n\n<pre><code>#!/bin/sh\n# Usage:  svnrevisions $file\n# Output: list of fully numeric svn revisions (without the r), one per line\n\nfile="$@"\n    svn log "$file" 2&gt; /dev/null | awk \'/^r[[:digit:]]+ \\|/ { sub(/^r/,"",$1); print  $1 }\'\n</code></pre>\n'}, {'answer_id': 11177097, 'author': 'Douglas Smith', 'author_id': 1478000, 'author_profile': 'https://Stackoverflow.com/users/1478000', 'pm_score': -1, 'selected': False, 'text': '<p>I came across this <a href="http://www.m0interactive.com/archives/2009/04/23/quick_way_searching_comments_from_svn_using_bash_script.html" rel="nofollow">bash script</a>, but I have not tried it.</p>\n'}, {'answer_id': 17473516, 'author': 'bahrep', 'author_id': 761095, 'author_profile': 'https://Stackoverflow.com/users/761095', 'pm_score': 5, 'selected': False, 'text': '<h2>Update April, 2022</h2>\n<p>VisualSVN Server 5.0 comes with a new <a href="https://www.visualsvn.com/server/features/search/" rel="nofollow noreferrer">full-text search</a> feature that allows you to search through the contents and history of your repositories in the web interface. Try out the feature on the <a href="https://demo-server.visualsvn.com/!/#asf/view/head/subversion/trunk" rel="nofollow noreferrer">demo server</a>.</p>\n<hr />\n<h2>Old answer</h2>\n<p><code>svn log</code> in Apache Subversion 1.8 supports <a href="http://subversion.apache.org/docs/release-notes/1.8.html#svn-log-search" rel="nofollow noreferrer">a new <code>--search</code> option</a>. So you can search Subversion repository history log messages without using 3\'rd party tools and scripts.</p>\n<p><code>svn log --search</code> searches in author, date, log message text and list of changed paths.</p>\n<p>See <a href="http://svnbook.red-bean.com/en/1.8/svn.ref.svn.c.log.html" rel="nofollow noreferrer">SVNBook | <code>svn log</code> command-line reference</a>.</p>\n'}, {'answer_id': 33120139, 'author': 'JREN', 'author_id': 2504013, 'author_profile': 'https://Stackoverflow.com/users/2504013', 'pm_score': 3, 'selected': False, 'text': "<pre><code>svn log -v [repository] &gt; somefile.log\n</code></pre>\n\n<p>for diff you can use the <code>--diff</code> option</p>\n\n<pre><code>svn log -v --diff [repository] &gt; somefile.log\n</code></pre>\n\n<p>then use vim or nano or whatever you like using, and do a search for what you're looking for. You'll find it pretty quickly.</p>\n\n<p>It's not a fancy script or anything automated. But it works.</p>\n"}, {'answer_id': 37855087, 'author': 'zednight', 'author_id': 1893975, 'author_profile': 'https://Stackoverflow.com/users/1893975', 'pm_score': 2, 'selected': False, 'text': '<p><code>svn log -l&lt;commit limit&gt; | grep -C&lt;5 or more lines&gt; &lt;search message&gt;</code></p>\n'}, {'answer_id': 38661105, 'author': 'DustWolf', 'author_id': 2897386, 'author_profile': 'https://Stackoverflow.com/users/2897386', 'pm_score': -1, 'selected': False, 'text': '<p>In case you are trying to determine which revision is responsible for a specific line of code, you are probably looking for:</p>\n\n<pre><code>svn blame\n</code></pre>\n\n<p>Credit: <a href="https://stackoverflow.com/a/283181/2897386">original answer</a></p>\n'}]
['https://Stackoverflow.com/questions/44176', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3408/']