summaryrefslogtreecommitdiffstats
path: root/source3/script/cvslog.pl
blob: f3d020aa722ed873249df55a385e7f1c8614dc5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/perl -w

my ( $tag, $filename, $date );
my ( $tmp, $change_flag );

if ( $#ARGV != 2 ) {

	print "Usage: ", $0, " cvstag date file\n";
	exit 1;
}

$tag      = $ARGV[0];
$date     = $ARGV[1];
$filename = $ARGV[2];

print STDERR "$filename\n";

open ( CVSLOG, "cvs log -d\"$date\" $filename |" ) || die $!;

##
## First get the branch revision number
##
undef $revision;
while ( !defined($revision) ) {
	if ( eof( \*CVSLOG ) ) {
		print STDERR "Premature end of cvs log output!\n";
		exit (1);
	}

	$string = <CVSLOG>;
	chomp( $string );

	if ( $string =~ /$tag:/ ) {
		( $tmp, $revision ) = split( /:/, $string );
		$revision =~ s/\s+//g;
		$revision =~ s/\.0\./\./g;
	}
}

##
## Setup the beginning of the first record
##
$string = "";
while ( $string !~ /^-+/ ) {
	$string = <CVSLOG>;
	exit(0) if ( eof(\*CVSLOG) );
}

##
## Loop starting at the revision number for the entry
##

while ( $string = <CVSLOG> ) {

	($tmp, $entry_rev) = split( /\s+/, $string );
	if ( equal_revision( $revision, $entry_rev ) ) {
		if ( ! defined($change_flag) ) {
			print "++++++++++++++++++++++++++++++++++++++++++++++++++\n";
			print "## $filename\n";
			print "++\n";
			$change_flag = 1;
		}

		while ( $string !~ /^-+/ && !eof(CVSLOG) ) {
			print "$string";
			$string = <CVSLOG>;
		}
	}
	else {
		while ( ($string !~ /^-+/) && !eof(CVSLOG) ) {
			$string = <CVSLOG>; 
		}
	}
}

close( CVSLOG );
exit 0;

##############################################################
##
sub equal_revision {
	my ( $branch, $newfile ) = @_;
	my ( $indx );
	my ( @branch_rev, @file_rev );

	@branch_rev = split( /\./, $branch );
	@file_rev = split( /\./, $newfile );

	return 0 if ( $#branch_rev != ($#file_rev - 1) );

	$indx = 0;
	while( $indx <= $#branch_rev ) {
		if ( $branch_rev[$indx] != $file_rev[$indx] ) {
			return 0;
		}
		$indx++;
	}

	return 1;
}