2000-02-08 17:13:55 +01:00
|
|
|
#!/usr/local/bin/perl -w
|
|
|
|
#
|
2000-02-08 17:58:28 +01:00
|
|
|
# $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} = "";
|
2000-02-08 17:58:28 +01:00
|
|
|
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} /) {
|
2000-02-08 17:58:28 +01:00
|
|
|
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});
|
2000-02-08 17:58:28 +01:00
|
|
|
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
|