8 |
|
|
9 |
extends 'Frey'; |
extends 'Frey'; |
10 |
with 'Frey::Web'; |
with 'Frey::Web'; |
11 |
#with 'Frey::Storage'; |
with 'Frey::Storage'; |
12 |
|
with 'Frey::HTML::Diff'; |
13 |
|
|
14 |
use XML::Simple; |
use XML::Simple; |
15 |
use DateTimeX::Easy; |
use DateTimeX::Easy; |
16 |
|
use Text::Diff::Parser; |
17 |
|
|
18 |
has repository => ( |
has repository => ( |
19 |
is => 'rw', |
is => 'rw', |
33 |
default => 50, |
default => 50, |
34 |
); |
); |
35 |
|
|
36 |
|
has include_diff => ( |
37 |
|
is => 'ro', |
38 |
|
isa => 'Bool', |
39 |
|
default => 1, |
40 |
|
); |
41 |
|
|
42 |
|
has file_stats => ( |
43 |
|
is => 'ro', |
44 |
|
isa => 'Bool', |
45 |
|
default => 1, |
46 |
|
); |
47 |
|
|
48 |
sub iterator { |
sub iterator { |
49 |
my ($self,$coderef) = @_; |
my ($self,$coderef) = @_; |
50 |
|
|
71 |
warn "# path $path\n"; |
warn "# path $path\n"; |
72 |
|
|
73 |
my $cmd; |
my $cmd; |
74 |
|
my $svn_path = $path; |
75 |
|
|
76 |
if ($path =~ m#file://# || -e "$path/.svn") { |
if ($path =~ m#file://# || -e "$path/.svn") { |
77 |
$cmd = "svn log -v --xml $path"; |
$cmd = "svn log -v --xml $path"; |
78 |
} else { |
} else { |
79 |
my $svn_path = sh_regex('svk info', qr#Mirrored From:\s+([^,]+)#i); |
$svn_path = sh_regex('svk info', qr#Mirrored From:\s+([^,]+)#i); |
80 |
|
|
81 |
if (! $svn_path) { |
if (! $svn_path) { |
82 |
|
|
113 |
|
|
114 |
foreach my $e (@{$xml->{'logentry'}}) { |
foreach my $e (@{$xml->{'logentry'}}) { |
115 |
warn "# e = ",$self->dump( $e ) if $self->debug; |
warn "# e = ",$self->dump( $e ) if $self->debug; |
116 |
|
|
117 |
|
if ( $self->include_diff || $self->file_stats ) { |
118 |
|
my $rev = $e->{'revision'}; |
119 |
|
my $file = $svn_path; |
120 |
|
$file =~ s{^\w+:/+}{}; |
121 |
|
my $file = "var/svn/$file/$rev.diff"; |
122 |
|
my $diff = $self->load( $file ); |
123 |
|
if ( ! $diff ) { |
124 |
|
$diff = `svn diff -c $rev $svn_path`; |
125 |
|
$self->store( $file, $diff ); |
126 |
|
} |
127 |
|
|
128 |
|
$e->{diff} .= $diff if $self->include_diff; |
129 |
|
|
130 |
|
$e->{diff_paths}->{rev} = $rev; # XXX debug |
131 |
|
|
132 |
|
my $diff_path; |
133 |
|
foreach my $line ( split(/[\n\r]/, $diff ) ) { |
134 |
|
if ( $line =~ m{^\+\+\+ (\S+)} ) { |
135 |
|
$diff_path = "/$1"; # subversion paths start with / |
136 |
|
} elsif ( $line =~ m{^\+} ) { |
137 |
|
$e->{diff_paths}->{$diff_path}->{added}++; |
138 |
|
} elsif ( $line =~ m{^-} ) { |
139 |
|
$e->{diff_paths}->{$diff_path}->{removed}++; |
140 |
|
} |
141 |
|
} |
142 |
|
} |
143 |
|
|
144 |
$coderef->($e); |
$coderef->($e); |
145 |
} |
} |
146 |
} |
} |
201 |
del { color: #c88 } |
del { color: #c88 } |
202 |
|); |
|); |
203 |
|
|
204 |
|
my $max_path_len = 0; |
205 |
|
my $path_count; |
206 |
|
|
207 |
$self->iterator( sub { |
$self->iterator( sub { |
208 |
my $e = shift; |
my $e = shift; |
209 |
|
|
232 |
} else { |
} else { |
233 |
push @files, $path; |
push @files, $path; |
234 |
} |
} |
235 |
|
|
236 |
|
$max_path_len = length $path if length $path > $max_path_len; |
237 |
|
$path_count->{$path}++; |
238 |
} |
} |
239 |
|
|
240 |
|
my $diff = $self->html_diff( $e->{diff} ) if $e->{diff}; |
241 |
|
|
242 |
|
$html .= $self->dump( $e->{diff_paths} ); |
243 |
|
|
244 |
$html .= qq| |
$html .= qq| |
245 |
<div class="commit"> |
<div class="commit"> |
246 |
<span class="date">$date</span> |
<span class="date">$date</span> |
250 |
| |
| |
251 |
. join("<br>\n", |
. join("<br>\n", |
252 |
map { |
map { |
253 |
qq|<a href="?repository=$repository;path=$_">$_</a>| |
my $path = $_; |
254 |
|
$path =~ s{<[^>]+>}{}g; |
255 |
|
qq|<a href="?repository=$repository;path=$path" title="$path ##">$_</a>| |
256 |
} @files |
} @files |
257 |
) |
) |
258 |
. qq| |
. qq| |
259 |
</div> |
</div> |
260 |
$msg |
$msg |
261 |
|
$diff |
262 |
</div> |
</div> |
263 |
|; |
|; |
264 |
|
|
265 |
}); |
}); |
266 |
|
|
267 |
|
$self->add_css(qq| |
268 |
|
.files { |
269 |
|
width: ${max_path_len}ex; |
270 |
|
} |
271 |
|
|); |
272 |
|
|
273 |
|
$html =~ s[title="(\S+) ##"]['title="' . $path_count->{$1} . '"']gse; |
274 |
|
|
275 |
return $html; |
return $html; |
276 |
} |
} |
277 |
|
|
291 |
|
|
292 |
foreach my $p (@{$e->{'paths'}->{'path'}}) { |
foreach my $p (@{$e->{'paths'}->{'path'}}) { |
293 |
my ($action,$path) = ($p->{'action'},$p->{'content'}); |
my ($action,$path) = ($p->{'action'},$p->{'content'}); |
294 |
$file_events .= qq|\t<event filename="$path" date="$date" author="$author" />\n|; |
my $weight = ''; |
295 |
|
if ( defined $e->{diff_paths}->{$path} ) { |
296 |
|
$weight = $e->{diff_paths}->{$path}->{removed}; |
297 |
|
$weight += $e->{diff_paths}->{$path}->{added} * 2; |
298 |
|
$weight = qq| weight="$weight" |; |
299 |
|
} |
300 |
|
$file_events .= qq|\t<event filename="$path" date="$date" author="$author"$weight/>\n|; |
301 |
} |
} |
302 |
|
|
303 |
}); |
}); |