--- trunk/lib/Frey/SVN.pm 2009/04/27 20:30:38 1069 +++ trunk/lib/Frey/SVN.pm 2009/04/27 21:06:40 1070 @@ -120,35 +120,38 @@ $e->{diff_paths}->{rev} = $rev; # XXX debug - my $diff_file = $svn_path; - $diff_file =~ s{^\w+:/+}{}; - mkpath "var/svn/$diff_file" unless -e "var/svn/$diff_file"; - $diff_file = "var/svn/$diff_file/$rev.diff"; - my $diff_fh; - my $diff_out; - if ( ! -e $diff_file || ! -s $diff_file ) { + my $cache = $svn_path; + $cache =~ s{^\w+:/+}{}; + $cache = "var/svn/$cache"; + mkpath $cache unless -e $cache; + my $diff_paths = $self->load( "$cache/$rev.yaml" ); + if ( ! $diff_paths ) { my $cmd = "svn diff -c $rev $svn_path"; - open($diff_fh, '-|', $cmd ) || die "can't open pipe from $cmd: $!"; - open($diff_out,'>' , $diff_file ) || die "can't write $diff_file: $!"; + my ( $diff_fh, $diff_out ); + my $diff_file = "$cache/$rev.diff"; + + open($diff_fh, '-|', $cmd) || die "can't open pipe from $cmd: $!"; + open($diff_out,'>' , $diff_file) || die "can't write $diff_file: $!"; warn "# creating $diff_file from $cmd\n"; - } else { - open($diff_fh, '<' , $diff_file ) || die "can't read $diff_file: $!"; - } - my $diff_path; + my $diff_path; - while( <$diff_fh> ) { - $e->{diff} .= $_ if $self->include_diff; - print $diff_out $_ if defined $diff_out; - - if ( m{^\+\+\+ (\S+)} ) { - $diff_path = "/$1"; # subversion paths start with / - } elsif ( m{^\+} && $diff_path ) { - $e->{diff_paths}->{$diff_path}->{added}++; - } elsif ( m{^-} && $diff_path ) { - $e->{diff_paths}->{$diff_path}->{removed}++; + while( <$diff_fh> ) { + print $diff_out $_; + + if ( m{^\+\+\+ (\S+)} ) { + $diff_path = "/$1"; # subversion paths start with / + } elsif ( m{^\+} && $diff_path ) { + $diff_paths->{$diff_path}->{added}++; + } elsif ( m{^-} && $diff_path ) { + $diff_paths->{$diff_path}->{removed}++; + } } + + $self->store( "$cache/$rev.yaml", $diff_paths ); } + $e->{diff} = $self->load( "$cache/$rev.diff" ) if $self->include_diff; + $e->{diff_paths} = $self->load( "$cache/$rev.yaml" ); } $coderef->($e); @@ -303,8 +306,10 @@ my ($action,$path) = ($p->{'action'},$p->{'content'}); my $weight = ''; if ( my $s = $e->{diff_paths}->{$path} ) { - $weight = $s->{removed} if $s->{removed}; - $weight += $s->{added} * 2 if $s->{added}; + + warn $self->dump( $s ); + $weight = $s->{removed} if defined $s->{removed}; + $weight += $s->{added} * 2 if defined $s->{added}; $weight = qq| weight="$weight" |; } $file_events .= qq|\t\n|;