开发者

How do I find/search/grep an SVN repository history?

开发者 https://www.devze.com 2023-01-15 19:01 出处:网络
I need to search through all revisions of a Subversion repository to find file names and revision numbers that contain a particular string. I know that this will find occurrences in a dump:

I need to search through all revisions of a Subversion repository to find file names and revision numbers that contain a particular string. I know that this will find occurrences in a dump:

svnadmin dump $REPO_PATH | grep -i "Verdana"

but the output is too cryptic. The output will include chunks of binary f开发者_如何学Goiles that match.

I have been using commands like this to search for strings in the current working copy of a project:

find . -name "*.css" -print0 | xargs -0 grep "Verdana"

The format of the output is useful, it give both filename and the line in which the string occurred:

./css/forms.css: font       : 12px Verdana;

Is there any way to search all revisions of an SVN repository for say, all .css files that contain a search string? And not just a word but a string with wildcards or a regular expression like grep?

Note: I have root access to the Linux server with the repository on it.

Also note: I do not wish to search a working copy, I need to search all revisions.


The easiest (and most effective I've found) way to do this, and it takes a little time investment up front - clone the svn repository into git, then use gitk to search the repository.

Since the entire repository is on your local system, it makes searching infinitely faster!

I used to manage a large subversion repository for roughly 30 developers, they'd often come to my desk asking, "can you find this change..", etc. I'd just fire up gitk!

svn log is horrendously slow as it has to hit the server. Also, if you have access to the server, you'll likely have to contrive some | grep -v or similar to weed out all the .svn directories.


Have you tried

svn log --verbose

on your root directory, printing each log message and all affected paths. It won't let you parse the file contents, but you my at least be able to search for .css files.


Think along the lines:

svn log $location -q | grep -P 'r\d+' -o | grep -P '\d+' -o | xargs -l1 svn diff -c | grep $pattern

I think by adjusting the flags you're giving to grep or writing a more complicated pipeline (possibly by piping to a loop instead of using xargs) you can grep SVN history for anything.

0

精彩评论

暂无评论...
验证码 换一张
取 消