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 |
sub iterator { |
sub iterator { |
43 |
my ($self,$coderef) = @_; |
my ($self,$coderef) = @_; |
44 |
|
|
65 |
warn "# path $path\n"; |
warn "# path $path\n"; |
66 |
|
|
67 |
my $cmd; |
my $cmd; |
68 |
|
my $svn_path = $path; |
69 |
|
|
70 |
if ($path =~ m#file://# || -e "$path/.svn") { |
if ($path =~ m#file://# || -e "$path/.svn") { |
71 |
$cmd = "svn log -v --xml $path"; |
$cmd = "svn log -v --xml $path"; |
72 |
} else { |
} else { |
73 |
my $svn_path = sh_regex('svk info', qr#Mirrored From:\s+([^,]+)#i); |
$svn_path = sh_regex('svk info', qr#Mirrored From:\s+([^,]+)#i); |
74 |
|
|
75 |
if (! $svn_path) { |
if (! $svn_path) { |
76 |
|
|
107 |
|
|
108 |
foreach my $e (@{$xml->{'logentry'}}) { |
foreach my $e (@{$xml->{'logentry'}}) { |
109 |
warn "# e = ",$self->dump( $e ) if $self->debug; |
warn "# e = ",$self->dump( $e ) if $self->debug; |
110 |
|
|
111 |
|
if ( $self->include_diff ) { |
112 |
|
my $rev = $e->{'revision'}; |
113 |
|
my $file = $svn_path; |
114 |
|
$file =~ s{^\w+:/+}{}; |
115 |
|
my $file = "var/svn/$path.diff"; |
116 |
|
my $diff = $self->load( $file ); |
117 |
|
if ( ! $diff ) { |
118 |
|
$diff = `svn diff -c $rev $svn_path`; |
119 |
|
$self->store( $file, $diff ); |
120 |
|
} |
121 |
|
$e->{diff} .= $diff; |
122 |
|
} |
123 |
|
|
124 |
$coderef->($e); |
$coderef->($e); |
125 |
} |
} |
126 |
} |
} |
181 |
del { color: #c88 } |
del { color: #c88 } |
182 |
|); |
|); |
183 |
|
|
184 |
|
my $max_path_len = 0; |
185 |
|
my $path_count; |
186 |
|
|
187 |
$self->iterator( sub { |
$self->iterator( sub { |
188 |
my $e = shift; |
my $e = shift; |
189 |
|
|
212 |
} else { |
} else { |
213 |
push @files, $path; |
push @files, $path; |
214 |
} |
} |
215 |
|
|
216 |
|
$max_path_len = length $path if length $path > $max_path_len; |
217 |
|
$path_count->{$path}++; |
218 |
} |
} |
219 |
|
|
220 |
|
my $diff = $self->html_diff( $e->{diff} ) if $e->{diff}; |
221 |
|
|
222 |
$html .= qq| |
$html .= qq| |
223 |
<div class="commit"> |
<div class="commit"> |
224 |
<span class="date">$date</span> |
<span class="date">$date</span> |
228 |
| |
| |
229 |
. join("<br>\n", |
. join("<br>\n", |
230 |
map { |
map { |
231 |
qq|<a href="?repository=$repository;path=$_">$_</a>| |
my $path = $_; |
232 |
|
$path =~ s{<[^>]+>}{}g; |
233 |
|
qq|<a href="?repository=$repository;path=$path" title="$path ##">$_</a>| |
234 |
} @files |
} @files |
235 |
) |
) |
236 |
. qq| |
. qq| |
237 |
</div> |
</div> |
238 |
$msg |
$msg |
239 |
|
$diff |
240 |
</div> |
</div> |
241 |
|; |
|; |
242 |
|
|
243 |
}); |
}); |
244 |
|
|
245 |
|
$self->add_css(qq| |
246 |
|
.files { |
247 |
|
width: ${max_path_len}ex; |
248 |
|
} |
249 |
|
|); |
250 |
|
|
251 |
|
$html =~ s[title="(\S+) ##"]['title="' . $path_count->{$1} . '"']gse; |
252 |
|
|
253 |
return $html; |
return $html; |
254 |
} |
} |
255 |
|
|