simple/cvsdiffmin/cvsdiffmin

70 lines
1.2 KiB
Plaintext
Raw Normal View History

2000-02-08 17:13:55 +01:00
#!/usr/local/bin/perl -w
#
# $Id: cvsdiffmin,v 1.2 2000-02-08 16:58:28 hjp Exp $
2000-02-08 17:13:55 +01:00
#
# cvsdiffmin - minimize output of cvs diff
#
use strict;
use File::Slurp;
my $diff = "/usr/local/bin/diff";
my $state = 'EQ';
my %text = ();
my %cap = ();
my $count = 0;
local $| = 1;
while (<>) {
if ($state eq 'EQ' && /^\<{7} /) {
$state = 'V1';
$text{$state} = "";
s/'/_/g;
2000-02-08 17:13:55 +01:00
$cap{$state} = $_;
next;
}
if ($state eq 'V1' && /^\={7}$/) {
$state = 'V2';
$text{$state} = "";
next;
}
if ($state eq 'V2' && /^\>{7} /) {
s/'/_/g;
2000-02-08 17:13:55 +01:00
$cap{$state} = $_;
write_file("cvsdiffmin.$$.$count.1", $text{V1});
write_file("cvsdiffmin.$$.$count.2", $text{V2});
open (DIFF,
"$diff " .
" --unchanged-group-format='\%='" .
" --changed-group-format='${cap{V1}}\%<=======\n\%>${cap{V2}}'" .
" --old-group-format='${cap{V1}}\%<=======\n\%>${cap{V2}}'" .
" --new-group-format='${cap{V1}}\%<=======\n\%>${cap{V2}}'" .
" cvsdiffmin.$$.$count.1" .
" cvsdiffmin.$$.$count.2" .
"|") or die "cannot invoke diff: $!";
while (<DIFF>) {
print;
}
close(DIFF);
2000-02-08 17:13:55 +01:00
$state = 'EQ';
$count++;
next;
}
if ($state eq 'EQ') {
print;
} else {
$text{$state} .= $_;
}
}
print "$state\n";
# vim:sw=4