a small script to show the different between the current file version and its last revision (requires Perl)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5078 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
e2b8b0662c
commit
35e20db0ee
76
difflast.pl
Executable file
76
difflast.pl
Executable file
@ -0,0 +1,76 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
###############################################################################
|
||||
# Name: difflast.pl
|
||||
# Purpose: Shows the difference between the current local version of the file
|
||||
# and the last cvs revision
|
||||
# Version: $Id$
|
||||
# Author: VZ
|
||||
# Created: 23.12.99
|
||||
# Copyright:(c) Vadim Zeitlin 1999
|
||||
###############################################################################
|
||||
|
||||
use strict;
|
||||
|
||||
my $CVS = "cvs -z3"; # the cvs command
|
||||
|
||||
sub dec_rev($)
|
||||
{
|
||||
my $rev = $_[0];
|
||||
|
||||
# decrement the revision number to get the previos one
|
||||
# (FIXME this is totally bogus, won't work with branches)
|
||||
my $revlen = length($rev) - rindex($rev, '.') - 1;
|
||||
my $m = 10**$revlen;
|
||||
|
||||
return int($rev) . "." . ($rev*$m - int($rev)*$m - 1)
|
||||
}
|
||||
|
||||
sub get_last_rev($)
|
||||
{
|
||||
my $file = $_[0];
|
||||
|
||||
my $basename = $file;
|
||||
$basename =~ s@^.*/([^/]\+)@$1@;
|
||||
|
||||
# first get the current version: try the Id RCS tag in the file itself
|
||||
# first, use "cvs status" if this fails
|
||||
if ( open(INPUT, $file) ) {
|
||||
while (<INPUT>) {
|
||||
if ( /\$Id$basename,v (\d+\.\d+)/ ) {
|
||||
return &dec_rev($1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
open(INPUT, "$CVS -q status $file |") or return 0;
|
||||
|
||||
while (<INPUT>) {
|
||||
if ( /Working revision:\s+(\d+\.\d+)/ ) {
|
||||
return &dec_rev($1);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub process_file($)
|
||||
{
|
||||
my $file = $_[0];
|
||||
my $revlast = &get_last_rev($file);
|
||||
|
||||
if ( !$revlast ) {
|
||||
warn "Failed to get the last revision for $file, skipping.\n"
|
||||
}
|
||||
else {
|
||||
print `$CVS diff -b -kk -r $revlast $file`;
|
||||
}
|
||||
}
|
||||
|
||||
# entry point
|
||||
|
||||
die "Usage: $0 <filenames...>\n" if ( $#ARGV == -1 );
|
||||
|
||||
foreach my $file (@ARGV) { process_file($file); }
|
||||
|
||||
exit 0;
|
Loading…
Reference in New Issue
Block a user