You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Ed Avis <ed...@waniasset.com> on 2008/09/01 14:04:47 UTC

How to grep the whole repository for a string?

Hi, I checked the Subversion FAQ but I can't see how to grep the whole
repository for a particular string.  Ideally, I would like something like

% svngrep foo file:///path/to/repo
something.c:r3-r10:blah blah foo blah
something.c:r2:blah blah foo blah fa
another.c:r3-r5:boo buu foo

so it would list the filename and the range of revisions between which it
contained that string.  Or something like that.

I could manually check out every revision of the repository since r1 and grep
all of them, but that seems wasteful.  Is there an efficient way to search the
whole repository for a string from the command line?

-- 
Ed Avis <ed...@waniasset.com>



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: How to grep the whole repository for a string?

Posted by Stephane Bortzmeyer <bo...@nic.fr>.
On Tue, Sep 02, 2008 at 03:30:00AM +0200,
 Lutz Dornbusch <sv...@yogasurftech.de> wrote 
 a message of 30 lines which said:

> outputs all(!) files from all(!) revisions 

Apparently no, only from the last revision.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

RE: How to grep the whole repository for a string?

Posted by Engebakken Geir <ge...@edb.com>.
As far as I can see this script only checks current revisionid, it doesnt examine the history of the repository!



Geir

-----Original Message-----
From: Lutz Dornbusch [mailto:svn@yogasurftech.de]
Sent: 2. september 2008 03:30
To: Ed Avis
Cc: users@subversion.tigris.org
Subject: Re: How to grep the whole repository for a string?

Ed Avis wrote:
> Hi, I checked the Subversion FAQ but I can't see how to grep the whole
> repository for a particular string.  Ideally, I would like something
> like
>
> % svngrep foo file:///path/to/repo
> something.c:r3-r10:blah blah foo blah
> something.c:r2:blah blah foo blah fa
> another.c:r3-r5:boo buu foo
>
> so it would list the filename and the range of revisions between which
> it contained that string.  Or something like that.
>
> I could manually check out every revision of the repository since r1
> and grep all of them, but that seems wasteful.  Is there an efficient
> way to search the whole repository for a string from the command line?
>

Hi,
I recently found this small script and it worked for me, however it is not rocket-science, but outputs all(!) files from all(!) revisions and greps, however if you do not have so many files inside, it may work.

<http://burningthornbush.blogspot.com/2007/11/small-tool-for-searching-in-svn-repos.html>

Greetings,
Lutz

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org


RE: How to grep the whole repository for a string?

Posted by Ed Avis <ed...@waniasset.com>.
Lutz Dornbusch <sv...@yogasurftech.de> wrote:

>I recently found this small script and it worked for me, 
>however it is not rocket-science, but outputs all(!) files 
>from all(!) revisions and greps, however if you do not have so 
>many files inside, it may work.
>
><http://burningthornbush.blogspot.com/2007/11/small-tool-for-searching-in-svn-repos.html>

Thanks - my repository is quite large and has lots of history, so I think this tool would be too slow.  I supposed there would be a tool to search the repository directly for a string without checking out every version.  It was easy to do in CVS :-p.

-- 
Ed Avis <ed...@waniasset.com>

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org


Re: How to grep the whole repository for a string?

Posted by Lutz Dornbusch <sv...@yogasurftech.de>.
Ed Avis wrote:
> Hi, I checked the Subversion FAQ but I can't see how to grep the whole
> repository for a particular string.  Ideally, I would like something like
> 
> % svngrep foo file:///path/to/repo
> something.c:r3-r10:blah blah foo blah
> something.c:r2:blah blah foo blah fa
> another.c:r3-r5:boo buu foo
> 
> so it would list the filename and the range of revisions between which it
> contained that string.  Or something like that.
> 
> I could manually check out every revision of the repository since r1 and grep
> all of them, but that seems wasteful.  Is there an efficient way to search the
> whole repository for a string from the command line?
> 

Hi,
I recently found this small script and it worked for me, however it is 
not rocket-science, but outputs all(!) files from all(!) revisions and 
greps, however if you do not have so many files inside, it may work.

<http://burningthornbush.blogspot.com/2007/11/small-tool-for-searching-in-svn-repos.html>

Greetings,
Lutz

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

RE: Re: How to grep the whole repository for a string?

Posted by Michael Maxwell <mm...@casl.umd.edu>.
Ed Avis <ed...@waniasset.com> wrote:
> Hi, I checked the Subversion FAQ but I can't see how to grep the
> whole repository for a particular string.

Yeah, I used to do that under RCS using the ordinary grep...

I see someone gave a pythonic way of doing it.  That's probably better than the shell script I wrote to do it.  I don't think I still have that around, but it went something like this:

for version_num in `svn -q log <fname> | grep the version numbers | cut the version numbers out` ; \
   do echo $version_num ; \
   svn cat -$version_num <fname> | grep <my_string> ; \
   done

   Mike Maxwell
   CASL/ U Md 

RE: How to grep the whole repository for a string?

Posted by Ed Avis <ed...@waniasset.com>.
>grephistory.py can be downloaded at
><http://www.bortzmeyer.org/files/grephistory.py>
>
>It is partially documented (in French only) at
><http://www.bortzmeyer.org/voyage-temporel-code-avec-le-vcs.html>.

Thanks!

You might want to change the name though, because it looks like 'grephistory' is already taken by another program.

-- 
Ed Avis <ed...@waniasset.com>

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org


Re: How to grep the whole repository for a string?

Posted by Stephane Bortzmeyer <bo...@nic.fr>.
On Mon, Sep 01, 2008 at 02:04:47PM +0000,
 Ed Avis <ed...@waniasset.com> wrote 
 a message of 18 lines which said:

> Hi, I checked the Subversion FAQ but I can't see how to grep the
> whole repository for a particular string.

% grephistory.py -a getaddrinfo echoping.c
"getaddrinfo" was added (as "getaddrinfo") in echoping.c at revision 152

grephistory.py can be downloaded at
<http://www.bortzmeyer.org/files/grephistory.py>

It is partially documented (in French only) at
<http://www.bortzmeyer.org/voyage-temporel-code-avec-le-vcs.html>.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org