[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

RE: svn grep -r2:5 "a_word" filename1 filename2 folder3

From: Reedick, Andrew <Andrew.Reedick_at_BellSouth.com>
Date: 2006-09-20 18:33:50 CEST

> -----Original Message-----
> From: Hanley, James [mailto:jhanley@redcom.com]
> Sent: Wednesday, September 20, 2006 11:58 AM
> To: users@subversion.tigris.org
> Subject: svn grep -r2:5 "a_word" filename1 filename2 folder3
>
> A while back, there was a request for the ability to grep through the
> source tree of subversion.
>
> http://subversion.tigris.org/servlets/ReadMsg?listName=users&m
sgNo=6804
>
> The response mentions using blame, but specifically I would like to
> search for (for example) some structure that existed at one point that
> was removed and what version it was removed from.
>
> The problem is that using svn blame seems to only produce the
> up-to-date
> snapshot of a given version. What I want is the last version
> the string
> was seen in.
>
> If there is a way of doing this without regressing through
> every version
> of a file, I would like to know, and if there is currently no way of
> doing this, I believe it would be a valuable feature to Subversion.

./rev_grep.sh URL[@PEG_REV] regex

The PEG_REV only works in svn 1.4.0 or higher. ('svn log' supports peg
revs in 1.4.0)

rev_grep.sh
=====================
#!/bin/ksh

URL=$1
REGEX=$2

LAST_REV="n/a"

svn log -q $URL | perl -ne 'print "$1\n" if /^r(\d+)/' |
while read r
do
    ##svn cat -r $r $URL | grep "$REGEX" > /dev/null
    BUFFER=`svn cat -r $r $URL | grep "$REGEX"`
    RET=$?
    if [ $RET -eq 0 ]
    then
        echo "Match in revision: $r. Removed in $LAST_REV."
        echo $BUFFER

        exit 0

    elif [ $RET -ne 1 ]
    then
        ## grep hit an error
        exit 2
    fi

    LAST_REV=$r
done
exit 1

*****

The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. GA624

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Wed Sep 20 18:38:07 2006

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.