Simple script to search in svn repository

This commit is contained in:
hjp 2010-09-13 13:15:58 +00:00
parent 0f501292a0
commit 3a526a613a
1 changed files with 32 additions and 0 deletions

32
svntools/svnsearch Executable file
View File

@ -0,0 +1,32 @@
#!/usr/bin/perl
use warnings;
use strict;
my $pattern = shift;
push @ARGV, "." unless (@ARGV);
for my $target (@ARGV) {
open(my $svnlog_fh, '-|', 'svn', 'log', $target) or die "cannot invoke svn log $target: $!";
my $atstart;
while (<$svnlog_fh>) {
if (/^------------------------------------------------------------------------$/) {
$atstart = 1;
next;
}
if ($atstart && /^r(\d+) \| /) {
my $revline = $_;
chomp $revline;
my $revision = $1;
open(my $svndiff_fh, '-|', 'svn', 'diff', "-c$revision", $target) or die "cannot invoke svn diff -c$revision $target: $!";
local $/ = undef;
my $diff = <$svndiff_fh>;
if ($diff =~ m/$pattern/) {
print "\n=== $revline ===\n$diff\n======\n\n";
}
}
$atstart = 0;
}
}
# vim: tw=0