Messages in this thread | | | Date | Thu, 3 Feb 2011 13:50:48 +0300 | From | Dan Carpenter <> | Subject | Re: rename_rev.pl script for reviewing renames |
| |
On Thu, Feb 03, 2011 at 11:22:19AM +0100, Wolfram Sang wrote: > On Thu, Feb 03, 2011 at 01:08:28PM +0300, Dan Carpenter wrote: > > There are a lot of refactoring patches where people change camel case > > names to kernel style names etc. I've written a script to make it > > easier to review them. It's attached. > > Cool, thanks for sharing. I guess my comments won't matter much, here > they are anyway :) >
Thanks for the review. I made the changes.
regards, dan carpenter #!/usr/bin/perl
use File::Temp qw/ :mktemp /;
sub usage() { print "usage: cat diff | $0 old new old new old new...\n"; exit(1); }
my @subs;
sub filter($) { my $line = shift();
foreach my $sub (@subs) { $line =~ s/$sub->[0]/$sub->[1]/g; }
# remove the first char $line =~ s/^[ +-]//;
return $line; }
($oldfh, $oldfile) = mkstemp("/tmp/oldXXXXX"); ($newfh, $newfile) = mkstemp("/tmp/newXXXXX");
while (my $param1 = shift()) { my $param2 = shift;
if ($param2 =~ /^$/) { usage(); } push @subs, [$param1, $param2]; }
while (<>) { my $line = $_;
if ($line =~ /^(---|\+\+\+)/) { next; }
my $output = filter($line); if ($line =~ /^-/) { print $oldfh $output; next; } if ($line =~ /^\+/) { print $newfh $output; next; } print $oldfh $output; print $newfh $output; }
system("diff -uw $oldfile $newfile");
unlink($oldfile); unlink($newfile);
| |