find svn revision by removed text

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

#!/bin/bash
file="$1"
REVISIONS=`svn log $file -q --stop-on-copy |grep "^r" | cut -d"r" -f2 | cut -d" " -f1`
for rev in $REVISIONS; do
    prevRev=$(($rev-1))
    difftext=`svn diff --old=$file@$prevRev --new=$file@$rev | tr -s " " | grep -v " -\ \- " | grep -e "$2"`
    if [ -n "$difftext" ]; then
        echo "$rev: $difftext"
    fi
done

pass the file name and search string on the command line:

xyz.sh "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.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)