summaryrefslogtreecommitdiff
path: root/devtools/bin/recentchanges.pl
blob: b0674b2267eca7dca6b546bee273d92248770910 (plain) (blame)
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
# usage: recentchanges.pl <changelist number> <filespec>
# 
# Outputs changelist notes for changelists starting at the changelist number until now
# that involve files in the filespec, grouped by user.
# 
# Output file is recentchanges.txt, output to the current working dir.

BEGIN {use File::Basename; push @INC, dirname($0); }
require "valve_perl_helpers.pl";

# take in the revision number we want and the filespec to look at 
my $from_changelist = shift;
my $branch = shift;

if ( length($from_changelist) < 1 || length($branch) < 1  )
{
	die "usage: recentchanges.pl <'from' changelist number> <filespec>";
}

my $cmd = "p4 changes -l $branch\@$from_changelist,\@now";
my @fstat = &RunCommand( $cmd );

my $lastuser;
my %changes;
	
foreach $line ( @fstat )
{	
	#if the line starts with "Change"
	#then store the user, all lines after this are changes by this user
	if ( $line =~ m/^Change/ )
	{					
		my $data = 'Change (1234) on (date) by (name)@(clientspec)';

		my @values = split(' ', $line);
		
		@usersplit = split('@', $values[5]);	
		
		$lastuser = $usersplit[0];				
	}
	else
	{
		#this is a change line, associate it with the user in our %changes hash
		
		chomp($line);
		
		# skip empty and 'merge from main' lines
		if ( length($line) > 0 && $line !~ m/Merge from main/ )
		{		
			#strip leading whitespace
			$line =~ s/^\s+//;
			
			# if the first char is not '-', add '- ' to the front
			if ( $line !~ m/^-/ )
			{
				$line = "- $line";
			}
			
			push @{ $changes{$lastuser} }, $line;
		}
	}
}

chdir();
open(OUTFILE, ">recentchanges.txt");

foreach $user ( keys %changes )
{
	print "$user\n";
    print OUTFILE "$user\n";
    foreach $i ( 0 .. $#{ $changes{$user} } )
    {
		print "$changes{$user}[$i]\n";
		print OUTFILE "$changes{$user}[$i]\n";
    }
    print "\n";
    print OUTFILE "\n";
}
 
close(OUTFILE);