120 |
|
|
121 |
$e->{diff_paths}->{rev} = $rev; # XXX debug |
$e->{diff_paths}->{rev} = $rev; # XXX debug |
122 |
|
|
123 |
my $diff_file = $svn_path; |
my $cache = $svn_path; |
124 |
$diff_file =~ s{^\w+:/+}{}; |
$cache =~ s{^\w+:/+}{}; |
125 |
mkpath "var/svn/$diff_file" unless -e "var/svn/$diff_file"; |
$cache = "var/svn/$cache"; |
126 |
$diff_file = "var/svn/$diff_file/$rev.diff"; |
mkpath $cache unless -e $cache; |
127 |
my $diff_fh; |
my $diff_paths = $self->load( "$cache/$rev.yaml" ); |
128 |
my $diff_out; |
if ( ! $diff_paths ) { |
|
if ( ! -e $diff_file || ! -s $diff_file ) { |
|
129 |
my $cmd = "svn diff -c $rev $svn_path"; |
my $cmd = "svn diff -c $rev $svn_path"; |
130 |
open($diff_fh, '-|', $cmd ) || die "can't open pipe from $cmd: $!"; |
my ( $diff_fh, $diff_out ); |
131 |
open($diff_out,'>' , $diff_file ) || die "can't write $diff_file: $!"; |
my $diff_file = "$cache/$rev.diff"; |
132 |
|
|
133 |
|
open($diff_fh, '-|', $cmd) || die "can't open pipe from $cmd: $!"; |
134 |
|
open($diff_out,'>' , $diff_file) || die "can't write $diff_file: $!"; |
135 |
warn "# creating $diff_file from $cmd\n"; |
warn "# creating $diff_file from $cmd\n"; |
|
} else { |
|
|
open($diff_fh, '<' , $diff_file ) || die "can't read $diff_file: $!"; |
|
|
} |
|
136 |
|
|
137 |
my $diff_path; |
my $diff_path; |
138 |
|
|
139 |
|
while( <$diff_fh> ) { |
140 |
|
print $diff_out $_; |
141 |
|
|
142 |
while( <$diff_fh> ) { |
if ( m{^\+\+\+ (\S+)} ) { |
143 |
$e->{diff} .= $_ if $self->include_diff; |
$diff_path = "/$1"; # subversion paths start with / |
144 |
print $diff_out $_ if defined $diff_out; |
} elsif ( m{^\+} && $diff_path ) { |
145 |
|
$diff_paths->{$diff_path}->{added}++; |
146 |
if ( m{^\+\+\+ (\S+)} ) { |
} elsif ( m{^-} && $diff_path ) { |
147 |
$diff_path = "/$1"; # subversion paths start with / |
$diff_paths->{$diff_path}->{removed}++; |
148 |
} elsif ( m{^\+} && $diff_path ) { |
} |
|
$e->{diff_paths}->{$diff_path}->{added}++; |
|
|
} elsif ( m{^-} && $diff_path ) { |
|
|
$e->{diff_paths}->{$diff_path}->{removed}++; |
|
149 |
} |
} |
150 |
|
|
151 |
|
$self->store( "$cache/$rev.yaml", $diff_paths ); |
152 |
} |
} |
153 |
|
$e->{diff} = $self->load( "$cache/$rev.diff" ) if $self->include_diff; |
154 |
|
$e->{diff_paths} = $self->load( "$cache/$rev.yaml" ); |
155 |
} |
} |
156 |
|
|
157 |
$coderef->($e); |
$coderef->($e); |
252 |
|
|
253 |
my $diff = $self->html_diff( $e->{diff} ) if $e->{diff}; |
my $diff = $self->html_diff( $e->{diff} ) if $e->{diff}; |
254 |
|
|
255 |
$html .= $self->dump( $e->{diff_paths} ); |
$self->add_css(qq| |
256 |
|
.diff-lines { |
257 |
|
margin-left: 1em; |
258 |
|
float: right; |
259 |
|
} |
260 |
|
|); |
261 |
|
|
262 |
$html .= qq| |
$html .= qq| |
263 |
<div class="commit"> |
<div class="commit"> |
270 |
map { |
map { |
271 |
my $path = $_; |
my $path = $_; |
272 |
$path =~ s{<[^>]+>}{}g; |
$path =~ s{<[^>]+>}{}g; |
273 |
qq|<a href="?repository=$repository;path=$path" title="$path ##">$_</a>| |
my $diff = ''; |
274 |
|
if ( $diff = $e->{diff_paths}->{$path} ) { |
275 |
|
$diff |
276 |
|
= qq|<span class="diff-lines">| |
277 |
|
. join(" ", |
278 |
|
map { |
279 |
|
my $v = $diff->{$_}; |
280 |
|
s[added][+$v]; |
281 |
|
s[removed][-$v]; |
282 |
|
$_; |
283 |
|
} keys %$diff |
284 |
|
) |
285 |
|
. qq|</span>| |
286 |
|
; |
287 |
|
warn "DIFF $diff"; |
288 |
|
} |
289 |
|
|
290 |
|
qq|$diff<a href="?repository=$repository;path=$path" title="$path ##">$_</a>| |
291 |
} @files |
} @files |
292 |
) |
) |
293 |
. qq| |
. qq| |
328 |
my ($action,$path) = ($p->{'action'},$p->{'content'}); |
my ($action,$path) = ($p->{'action'},$p->{'content'}); |
329 |
my $weight = ''; |
my $weight = ''; |
330 |
if ( my $s = $e->{diff_paths}->{$path} ) { |
if ( my $s = $e->{diff_paths}->{$path} ) { |
331 |
$weight = $s->{removed} if $s->{removed}; |
|
332 |
$weight += $s->{added} * 2 if $s->{added}; |
warn $self->dump( $s ); |
333 |
|
$weight = $s->{removed} if defined $s->{removed}; |
334 |
|
$weight += $s->{added} * 2 if defined $s->{added}; |
335 |
$weight = qq| weight="$weight" |; |
$weight = qq| weight="$weight" |; |
336 |
} |
} |
337 |
$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|; |