7 |
# 2004-04-28 Dobrica Pavlinusic <dpavlin@rot13.org> |
# 2004-04-28 Dobrica Pavlinusic <dpavlin@rot13.org> |
8 |
|
|
9 |
extends 'Frey'; |
extends 'Frey'; |
10 |
with 'Frey::Web'; |
with 'Frey::Web', 'Frey::Storage', 'Frey::HTML::Diff'; |
|
with 'Frey::Storage'; |
|
|
with 'Frey::HTML::Diff'; |
|
11 |
|
|
12 |
use XML::Simple; |
use XML::Simple; |
13 |
use DateTimeX::Easy; |
use DateTimeX::Easy; |
108 |
} |
} |
109 |
close($fh); |
close($fh); |
110 |
|
|
111 |
|
warn "got ", length($log), " bytes of XML changes\n"; |
112 |
|
|
113 |
my $xml = XMLin($log, ForceArray => [ 'logentry', 'path' ]); |
my $xml = XMLin($log, ForceArray => [ 'logentry', 'path' ]); |
114 |
|
|
115 |
foreach my $e (@{$xml->{'logentry'}}) { |
foreach my $e (@{$xml->{'logentry'}}) { |
118 |
if ( $self->include_diff || $self->file_stats ) { |
if ( $self->include_diff || $self->file_stats ) { |
119 |
my $rev = $e->{'revision'}; |
my $rev = $e->{'revision'}; |
120 |
|
|
121 |
|
warn "# revision $rev\n" if $rev % 100 == 0; |
122 |
|
|
123 |
$e->{diff_paths}->{rev} = $rev; # XXX debug |
$e->{diff_paths}->{rev} = $rev; # XXX debug |
124 |
|
|
125 |
my $cache = $svn_path; |
my $cache = $svn_path; |
126 |
$cache =~ s{^\w+:/+}{}; |
$cache =~ s{^\w+:/+}{}; |
127 |
$cache = "var/svn/$cache"; |
$cache = "var/svn/$cache"; |
128 |
mkpath $cache unless -e $cache; |
mkpath $cache unless -e $cache; |
129 |
my $diff_paths = $self->load( "$cache/$rev.yaml" ); |
|
130 |
if ( ! $diff_paths ) { |
my $diff_path = "$cache/$rev.diff"; |
131 |
|
$e->{diff} = $self->load( $diff_path ) if $self->include_diff && -e $diff_path; |
132 |
|
|
133 |
|
my $diff_yaml = "$cache/$rev.yaml"; |
134 |
|
|
135 |
|
if ( -e $diff_yaml ) { |
136 |
|
$e->{diff_paths} = $self->load( $diff_yaml ); |
137 |
|
} else { |
138 |
my $cmd = "svn diff -c $rev $svn_path"; |
my $cmd = "svn diff -c $rev $svn_path"; |
139 |
my ( $diff_fh, $diff_out ); |
my ( $diff_fh, $diff_out ); |
140 |
my $diff_file = "$cache/$rev.diff"; |
my $diff_file = "$cache/$rev.diff"; |
141 |
|
|
142 |
open($diff_fh, '-|', $cmd) || die "can't open pipe from $cmd: $!"; |
open($diff_fh, '-|', $cmd) || die "can't open pipe from $cmd: $!"; |
143 |
open($diff_out,'>' , $diff_file) || die "can't write $diff_file: $!"; |
open($diff_out,'>' , $diff_file) || die "can't write $diff_file: $!"; |
144 |
warn "# creating $diff_file from $cmd\n"; |
#warn "# creating $diff_file from $cmd\n"; |
145 |
|
|
146 |
my $diff_path; |
my $diff_path; |
147 |
|
my $changes; |
148 |
|
my $diff = ''; |
149 |
|
|
150 |
while( <$diff_fh> ) { |
while( <$diff_fh> ) { |
151 |
|
$diff .= $_; |
152 |
print $diff_out $_; |
print $diff_out $_; |
153 |
|
|
154 |
if ( m{^\+\+\+ (\S+)} ) { |
if ( m{^\+\+\+ (\S+)} ) { |
155 |
$diff_path = "/$1"; # subversion paths start with / |
$diff_path = "/$1"; # subversion paths start with / |
156 |
} elsif ( m{^\+} && $diff_path ) { |
} elsif ( m{^\+} && $diff_path ) { |
157 |
$diff_paths->{$diff_path}->{added}++; |
$changes->{$diff_path}->{added}++; |
158 |
} elsif ( m{^-} && $diff_path ) { |
} elsif ( m{^-} && $diff_path ) { |
159 |
$diff_paths->{$diff_path}->{removed}++; |
$changes->{$diff_path}->{removed}++; |
160 |
} |
} |
161 |
} |
} |
162 |
|
|
163 |
$self->store( "$cache/$rev.yaml", $diff_paths ); |
$e->{diff} = $diff if $self->include_diff; |
164 |
|
|
165 |
|
$self->store( "$cache/$rev.yaml", $changes ); |
166 |
|
$e->{diff_paths} = $changes; |
167 |
} |
} |
168 |
$e->{diff} = $self->load( "$cache/$rev.diff" ) if $self->include_diff; |
|
|
$e->{diff_paths} = $self->load( "$cache/$rev.yaml" ); |
|
169 |
} |
} |
170 |
|
|
171 |
$coderef->($e); |
$coderef->($e); |
327 |
+ length( $stats->{total_removed} ) |
+ length( $stats->{total_removed} ) |
328 |
; |
; |
329 |
|
|
330 |
$max_path_len += int( $max_path_len / 10 ); # we are using ex, so we add 10% |
$max_path_len += int( $max_path_len / 4 ); # we are using ex, so we adjust length |
331 |
|
|
332 |
$self->add_css(qq| |
$self->add_css(qq| |
333 |
.files { |
.files { |
360 |
my ($action,$path) = ($p->{'action'},$p->{'content'}); |
my ($action,$path) = ($p->{'action'},$p->{'content'}); |
361 |
my $weight = ''; |
my $weight = ''; |
362 |
if ( my $s = $e->{diff_paths}->{$path} ) { |
if ( my $s = $e->{diff_paths}->{$path} ) { |
363 |
$weight = $s->{removed} if defined $s->{removed}; |
$weight = $s->{removed} || 0; |
364 |
$weight += $s->{added} * 2 if defined $s->{added}; |
$weight += $s->{added} * 2 if $s->{added}; |
365 |
$weight = qq| weight="$weight" |; |
$weight = qq| weight="$weight" |; |
366 |
} |
} |
367 |
$file_events .= qq|\t<event filename="$path" date="$date" author="$author"$weight/>\n|; |
$file_events .= qq|\t<event filename="$path" date="$date" author="$author"$weight/>\n|; |
369 |
|
|
370 |
}); |
}); |
371 |
|
|
372 |
|
warn "generated ",length($file_events)," bytes of file events\n"; |
373 |
|
|
374 |
return qq|<?xml version="1.0"?> |
return qq|<?xml version="1.0"?> |
375 |
<!-- One commit per day for one month by a documenter and programmer. --> |
<!-- One commit per day for one month by a documenter and programmer. --> |
376 |
<file_events> |
<file_events> |
380 |
|
|
381 |
} |
} |
382 |
|
|
383 |
|
__PACKAGE__->meta->make_immutable; |
384 |
|
no Moose; |
385 |
|
|
386 |
1; |
1; |