The Perl Toolchain Summit 2025 Needs You: You can help 🙏 Learn more

#!/usr/bin/perl
$| = 1;
use VCS;
if (scalar(@ARGV) == 0) {
die 'Usage: diff-hist file [file...]';
}
foreach my $arg (@ARGV) {
my $file = VCS::File->new($arg);
my @versions = $file->versions;
my @diff_pairs;
for (my $count = @versions - 1; $count > 0; $count--) {
push @diff_pairs, [ $versions[$count - 1], $versions[$count] ];
}
map {
my $old = $_->[0];
my $new = $_->[1];
print
'*** Changes from version ',
$old->version,
' to version ',
$new->version,
' (',
$new->date,
")\n",
'What: ', $new->path, "\n",
'Version: ', $new->version, "\n",
'When: ', $new->date, "\n",
'Who: ', $new->author, "\n",
'Tags: ', (join "\n ", $new->tags), "\n",
'Why: ', (join "\n ", $new->reason), "\n",
$old->diff($new)
} @diff_pairs;
}
__END__
=head1 NAME
diff-hist - View revision history of file under version control
=head1 SYNOPSIS
diff-hist file [file...]
=head1 DESCRIPTION
For each file specified, the differences (in diff -u2 format) are shown
between each successive version back to the first, in reverse
chronological order.
=head1 SEE ALSO
L<VCS>.