summaryrefslogtreecommitdiff
path: root/d/sys/lampion/local/sbin/svnlog
diff options
context:
space:
mode:
Diffstat (limited to 'd/sys/lampion/local/sbin/svnlog')
-rwxr-xr-xd/sys/lampion/local/sbin/svnlog74
1 files changed, 74 insertions, 0 deletions
diff --git a/d/sys/lampion/local/sbin/svnlog b/d/sys/lampion/local/sbin/svnlog
new file mode 100755
index 0000000..51af104
--- /dev/null
+++ b/d/sys/lampion/local/sbin/svnlog
@@ -0,0 +1,74 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+
+use Template;
+use Getopt::Long qw(:config no_ignore_case);
+
+my $repos;
+my $template;
+my $n_old_revision = 10;
+my $svnlook = 'svnlook';
+
+sub parse_revision
+{
+ my ($r, $rev) = @_;
+ # General Information
+ my @cmd = `$svnlook --revision $r info $repos`;
+ map { chomp; } @cmd;
+ $$rev{rev} = $r;
+ $$rev{author} = shift @cmd;
+ $$rev{date} = shift @cmd;
+ shift @cmd; # log message size
+ pop @cmd while (@cmd && $cmd[-1] eq ''); # remove empty lines
+ $$rev{msg} = \@cmd;
+ # Changed
+ open OUT, "$svnlook --revision $r changed $repos|";
+ while (<OUT>)
+ {
+ if (/^([A-Z])\s+(.+)$/)
+ {
+ push @{$$rev{add}}, $2 and next if $1 eq 'A';
+ push @{$$rev{upd}}, $2 and next if $1 eq 'U';
+ push @{$$rev{del}}, $2 and next if $1 eq 'D';
+ }
+ }
+}
+
+sub usage
+{
+ print "Usage: $0 [ -n number of revisions to show ] -t template dir -r reposotory\n";
+ exit 0;
+}
+
+sub config
+{
+ my $help;
+ GetOptions ("h" => \$help,
+ "t=s" => \$template,
+ "n=i" => \$n_old_revision,
+ "r=s" => \$repos
+ );
+ die usage () if ((!defined $template and !defined $repos) or defined $help);
+}
+
+{
+ # Collect data
+ config ();
+ my $cur_rev =`$svnlook youngest $repos`;
+ chomp $cur_rev;
+ my $last_rev = $cur_rev - $n_old_revision;
+ $last_rev = 0 if ($last_rev < 0);
+ my @revisions;
+ for (my $i = $cur_rev; $i > $last_rev; $i --)
+ {
+ my %revision;
+ parse_revision ($i, \%revision);
+ push @revisions, \%revision;
+ }
+ # Print it
+ my $tt = new Template ({ INCLUDE_PATH => $template });
+ $tt->process ('html.tt', { revisions => \@revisions })
+ or die $tt->error;
+}