[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: searching all code changes
From: |
bernd |
Subject: |
Re: searching all code changes |
Date: |
4 Aug 2006 06:24:07 -0700 |
User-agent: |
G2/0.2 |
hi again, i implemented cvs-scan a short perl script going for text
patterns inside the repository. It is neither beautiful nor clever but
all i need for now.
cvs-scan
--BOF--
#!/usr/bin/perl -w
$usage=<<EOT;
NAME
cvs-scan - Scan Repository for Textpatterns
SYNOPSIS
cvs-scan SEARCHPATTERN FILEPATTERN
cvs-scan traverses the \$CVSROOT directorytree and reports all
repository files
containing SEARCHPATTERN along with relevant revision numbers.
SEARCHPATTERN is a perl regexp pattern (excluding slashes) you're
trying to find
in your repository.
FILEPATTERN is a perl regexp for the filenames you want to search
in.
DEPENDENCIES
Uses the \$CVSROOT environment variable.
EXAMPLE
Looking for all files and revisions mentioning 'someFunction' use:
cvshost>> cvs-scan someFunction ''
or from remote
remote>> ssh cvshost cvs-scan someFunction ''
AUTHOR
Bernd Worsch <address@hidden>
EOT
if ($#ARGV < 1) {
print $usage;
exit;
}
$searchpattern = shift @ARGV;
$filepattern = shift @ARGV;
$filepattern .= '\,v';
print "cvs search for '$searchpattern' in '$filepattern' files...\n";
use File::Find;
sub scan {
return unless /$main::filepattern/;
$filename = $_;
$buffer = ''; $at_count = 0; $match_found = 0;
open FILE, "<", $filename || die;
while (<FILE>) {
$line = $_;
if ($line =~ /\d+\.\d+(\.\d+)*/) {
$buffer = ''; $at_count = 0; $match_found = 0;
}
$buffer .= $line;
$match_found = 1 if $line =~ /$main::searchpattern/i;
$at_count++ if $line =~ /\@/;
if ($match_found && $at_count == 4) {
print "@@ $File::Find::name\n";
print $buffer;
$buffer = ''; $at_count = 0; $match_found = 0;
}
}
close FILE;
}
find(\&scan, $ENV{'CVSROOT'});
--EOF--