File indexing completed on 2024-04-21 05:41:57

0001 #!/usr/bin/perl -w
0002 # Written by Zack Rusin <zack@kde.org>
0003 #
0004 # This file is free software, licensed under the BSD licence. 
0005 # That means that you can do anything you want with it except 
0006 # eating too much candy since that totally messes up your teeth
0007 # and here in KDE land we care about your teeth. They're out 
0008 # greatest priority right next to scoring chicks of course...
0009 #
0010 
0011 # This script goes through the whole history of a file to find 
0012 # all modifications referencing specific string. It's useful if
0013 # you want to know when a function has been removed/modified/added
0014 # to a file if a recent cvs annotate doesn't anymore reference it.
0015 
0016 our $file;
0017 our $func;
0018 
0019 sub check_file
0020 {
0021   my $rev1 = shift;
0022   my $rev2 = shift;
0023 
0024   my $output = `cvs diff -r $rev1 -r $rev2 $file`;
0025 
0026   if ( $output =~ /(^[+-].+$func.+$)/m ) {
0027     print "FOUND IN: cvs diff -r $rev1 -r $rev2 $file\n";
0028     $_ = $1;
0029     s/^([-+])\s*(.+)/$1 $2/;
0030     return $_;
0031   }
0032   return 0;
0033 }
0034 
0035 sub get_revision
0036 {
0037   my $output = `cvsversion $file`;
0038   chomp $output;
0039   return $output;
0040 }
0041 
0042 my $argc = scalar @ARGV;
0043 
0044 die "$0 <function> <file>" if ( $argc != 2 );
0045 $func = $ARGV[0];
0046 $file = $ARGV[1];
0047 
0048 my $current_revision = get_revision( $file );
0049 
0050 $current_revision =~ /(\d+)\.(\d+)/;
0051 $base = $1;
0052 $working = $2;
0053 
0054 while ( $working > 1 ) {
0055   my $older = $working - 1;
0056   my $res = check_file( "$base.$older", "$base.$working");
0057   
0058   if ( $res ) {
0059     print "\t($res)\n";
0060   }
0061   --$working;
0062 }
0063 
0064 print "Didn't find a reference to that $func in $file\n";