Line # Revision Author
1 3 ahitrov@rambler.ru #!/usr/bin/perl
2
3 use strict;
4 use warnings 'all';
5 use locale;
6
7 use FindBin;
8 use Getopt::Std;
9
10
11 my %opts;
12 getopts('hir', \%opts);
13
14 &usage if $opts{h};
15 &usage unless $#ARGV==1;
16
17 my @revs = grep {$_} map {/^r(\d+)/; $1} `svn log -q $ARGV[0]`;
18 @revs = reverse @revs unless $opts{r};
19 exit unless @revs;
20
21 $|=1;
22 for my $r (0..$#revs-1) {
23 my @out = map {
24 "$revs[$r]:$revs[$r+1] : $_"
25 } `svn di -r$revs[$r]:$revs[$r+1] $ARGV[0] | egrep '^[\+\-]' | egrep -v [\+\-]{3}`;
26 if ($opts{i}) {
27 @out = grep {/$ARGV[1]/i} @out;
28 } else {
29 @out = grep {/$ARGV[1]/} @out;
30 }
31 print join '', @out;
32 }
33
34
35 sub usage {
36 print <<EOM;
37 Usage:
38 $FindBin::RealScript [options] {file|URL} pattern
39
40 Options:
41 -h Print this help message
42 -i Ignore case
43 -r Reverse search
44 EOM
45 exit;
46 }