2 # Creates a statistic of Pugs' development.
3 # Usage: svn log | util/svnlog2graph.pl > /tmp/graph.png --or
4 # svn log > /tmp/log; util/svnlog2graph /tmp/log > /tmp/graph.png
19 print STDERR
<<INFO unless @ARGV;
20 Pipe output of "svn log" or save "svn log" output in a file and
21 specify this file as parameter.
22 Output will go to STDOUT in PNG format.
27 # Only process headlines
28 next unless m/^r/ and m/lines?$/ and m/\|/;
29 my ($dev, $date) = (split / \| /)[1, 2];
30 $date =~ s/ [+-]\d+ \(.*$//;
32 # Example: $date is now "2005-02-06 17:52:06"
33 my $time = Time
::Piece
->strptime($date, "%Y-%m-%d %H:%M:%S");
35 push @developers, $time unless $devs_seen{$dev}++;
39 # $commits[0] should be first commit, not last
40 @commits = reverse @commits;
41 @developers = reverse @developers;
43 # Collect commits in days
44 # E.g. $commits_till_day[42] = 1500 (1500 commits from day 1 to day 42)
45 my @commits_till_day = dayify
(@commits);
46 my @devs_till_day = dayify
(@developers);
47 # @devs_till_day should have the same length as @commits_till_day --
49 push @devs_till_day, $devs_till_day[-1] while
50 @devs_till_day < @commits_till_day;
53 my $graph = GD
::Graph
::lines
->new(500, 350);
55 title
=> "Pugs development",
57 y_label
=> "Commits/Developers",
59 y_max_value
=> (int(@commits / 500) + 1) * 500,
60 ) or die $graph->error;
63 [ 0..@commits_till_day ], # Day#
64 [ 0, @commits_till_day ], # Commits
65 [ 0, map { 50 * $_ } @devs_till_day ], # Developers (scaled)
68 my $gd = $graph->plot(\
@data) or die $graph->error;
72 # Input: (2, 5, 9, 86400+17, 2*86400+35, 4*86400+50)
73 # Output: (3, 4, 5, 5, 6)
78 my $cur_day = int(($_ - $_[0]) / ONE_DAY
);
80 if($cur_day != $#till_day) {
81 push @till_day, $till_day[-1] || 0
82 while $#till_day < $cur_day;