find svn revision by removed text

Is there a way to find an SVN revision by searching for a text string that got removed in the file? I know the exact text to search for and which file to look in, but there are hundreds of revisions.

Svn revision number to a text file

I want to display svn revision number to a text file I am getting the revision number using this command $revision = ([xml](svn info filepath –xml)).info.entry.commit.revision

SVN find revision of tag

Is there any way of showing which revision is equivalent to a certain tag?

find out SVN revision on Server from shell

Is it possible to find out the current revision of the SVN repo from a bash script. I thought I could do that with svnversion … REV=`svnversion http://host/path/to/svn` … but it only works with l

How do I find out who the author of a revision is in SVN?

How do I find out who the author of a revision is in SVN?

Is there an svn command to find out the last revision to change a particular file or a directory?

Is there an svn command to find out the last revision to change a particular file or a directory?

Find Removed text in JTextPane

I am learning about DocumentListener in java with JTextPane. I’m trying to get the current string or word (text) which is inserted/removed recently in textpane. I’ve tried this: import javax.swing.*;

svn:externals ignoring specified revision

I’m using svn:externals and I’ve specified a specific revision using the SVN1.5+ format, but SVN seems to ignore the revision number. $ svn –version svn, version 1.6.17 (r1128011) $ svn propget svn:e

Restoring removed commits in SVN

I’ve removed a commit from trunk, for example commit 100: svn -r 100:99 . and I’ve committed the change so that revision 100 is no longer in trunk. Is there a way to put revision 100 back into trunk?

removed all text

removed all text removed all text removed all text

Tortoise SVN revision history

I want to know for how long the tortoise svn keeps the revision history. Say I have a file which I deleted from repository through repo browser an year ago, will I be able to still recover that file?


just a little bash script which filters out the changed lines…If you change pom.xml into your file may with supplemental URL you have what you need…(If you are on Unix like system). Put the following into a script file ( and do a filter on the output.

REVISIONS=`svn log pom.xml -q|grep "^r" | cut -d"r" -f2 | cut -d" " -f1`
for rev in $REVISIONS; do
    svn blame -r$rev:$rev pom.xml | tr -s " " | grep -v " -/ /- "
done | grep "Text you are searching for"

The printout will be something like:

256 ......

The 256 is the revision in which the change had been made.

Building on khmarbaise’s script, I came up with this:

REVISIONS=`svn log $file -q --stop-on-copy |grep "^r" | cut -d"r" -f2 | cut -d" " -f1`
for rev in $REVISIONS; do
    difftext=`svn diff [email protected]$prevRev [email protected]$rev | tr -s " " | grep -v " -/ /- " | grep -e "$2"`
    if [ -n "$difftext" ]; then
        echo "$rev: $difftext"

pass the file name and search string on the command line: "filename" "text to search"

svn diff gives me both the rev where it’s added and where it’s deleted; I’ll leave it here in case it’s useful to anyone. There’s an error message at the last revision that I don’t know how to get rid of (I still got a lot of bash to learn šŸ™‚ ) but the rev numbers are correct.

I like

It’s output for a file contains all existing and deleted lines so that I can see the deleted lines in the surrounding context.

Made a simple PHP version of the accepted answer to be run on the command line:

$file = $argv[1];
$searchfor = $argv[2];

if (!$file) die('Please specify file name to search through as the first argument.');
if (!$searchfor) die('Please specify text to search for as the second argument.');

echo PHP_EOL .'Searching '. $file .' for: '. $searchfor . PHP_EOL . PHP_EOL;

$cmd = 'svn log '. $file .' -q';
$output = array();
exec($cmd, $output);

// Find all revisions
$all_revisions = array();
foreach ($output as $line) {
    if (preg_match("/^r(//d+) /", $line, $match)) {
        $all_revisions[] = $match[1];

echo 'Checking '. count($all_revisions) .' revisions...'. PHP_EOL . PHP_EOL;

// Get diff for each revision
foreach ($all_revisions as $keykey => $rev) {
    $prev_rev = $all_revisions[$keykey+1];

    $cmd = 'svn diff --old='. $file .'@'. $prev_rev .' --new='. $file .'@'. $rev;
    $output = array();
    exec($cmd, $output);

    // Check if string is present
    $str = implode(PHP_EOL, $output);
    if (strpos($str, $searchfor) !== false) {
        echo 'Found in revision '. $prev_rev .' but removed from '. $rev .'.'. PHP_EOL;
    } else {
        echo 'Not found in revision '. $rev .'.'. PHP_EOL;
echo 'Done.'. PHP_EOL;

Run the script the script with the following command:

php scriptname.php “filetosearchthrough.php” “text to search for”

The script could be fine-tuned but does what you need. Keep in mind that it takes a long time to search through many revisions.