]> git.saurik.com Git - wxWidgets.git/blame - difflast.pl
ignore dmc_lib (Digital Mars build directory)
[wxWidgets.git] / difflast.pl
CommitLineData
35e20db0
VZ
1#!/usr/bin/perl -w
2
3###############################################################################
4# Name: difflast.pl
5# Purpose: Shows the difference between the current local version of the file
6# and the last cvs revision
7# Version: $Id$
8# Author: VZ
9# Created: 23.12.99
10# Copyright:(c) Vadim Zeitlin 1999
11###############################################################################
12
13use strict;
14
15my $CVS = "cvs -z3"; # the cvs command
16
f6bcfd97
BP
17# the regexp for cvs revision number
18my $RE_CVS_REV = "\\d+(?:\\.\\d+)+";
19
35e20db0
VZ
20sub dec_rev($)
21{
22 my $rev = $_[0];
23
24 # decrement the revision number to get the previos one
f6bcfd97 25 $rev =~ s/(\d+)$/$1 - 1/e;
35e20db0 26
f6bcfd97 27 return $rev;
35e20db0
VZ
28}
29
30sub get_last_rev($)
31{
32 my $file = $_[0];
33
34 my $basename = $file;
9239628c 35 $basename =~ s@^.*/@@;
35e20db0
VZ
36
37 # first get the current version: try the Id RCS tag in the file itself
38 # first, use "cvs status" if this fails
39 if ( open(INPUT, $file) ) {
40 while (<INPUT>) {
c7d68b4b
VZ
41 # notice that we shouldn't have '$' followed by 'Id' or cvs will
42 # substitute it!
f6bcfd97 43 if ( /\$(Id): $basename,v ($RE_CVS_REV)/ ) {
c7d68b4b 44 return &dec_rev($2);
35e20db0
VZ
45 }
46 }
47 }
48
49 open(INPUT, "$CVS -q status $file |") or return 0;
50
51 while (<INPUT>) {
f6bcfd97 52 if ( /Working revision:\s+($RE_CVS_REV)/ ) {
35e20db0
VZ
53 return &dec_rev($1);
54 }
55 }
56
57 return 0;
58}
59
60sub process_file($)
61{
62 my $file = $_[0];
63 my $revlast = &get_last_rev($file);
64
65 if ( !$revlast ) {
66 warn "Failed to get the last revision for $file, skipping.\n"
67 }
9239628c 68 elsif ( $revlast =~ '\.0' ) {
c7d68b4b
VZ
69 warn "No previous revision of the file $file.\n"
70 }
35e20db0
VZ
71 else {
72 print `$CVS diff -b -kk -r $revlast $file`;
73 }
74}
75
76# entry point
77
78die "Usage: $0 <filenames...>\n" if ( $#ARGV == -1 );
79
80foreach my $file (@ARGV) { process_file($file); }
81
82exit 0;