/[Frey]/trunk/lib/Frey/SVN.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/Frey/SVN.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1067 by dpavlin, Mon Apr 27 19:55:32 2009 UTC revision 1068 by dpavlin, Mon Apr 27 20:30:20 2009 UTC
# Line 14  with 'Frey::HTML::Diff'; Line 14  with 'Frey::HTML::Diff';
14  use XML::Simple;  use XML::Simple;
15  use DateTimeX::Easy;  use DateTimeX::Easy;
16  use Text::Diff::Parser;  use Text::Diff::Parser;
17    use File::Path qw/mkpath/;
18    
19  has repository => (  has repository => (
20          is => 'rw',          is => 'rw',
# Line 36  has limit => ( Line 37  has limit => (
37  has include_diff => (  has include_diff => (
38          is => 'ro',          is => 'ro',
39          isa => 'Bool',          isa => 'Bool',
40          default => 1,          default => 0,
41  );  );
42    
43  has file_stats => (  has file_stats => (
# Line 116  sub iterator { Line 117  sub iterator {
117    
118                  if ( $self->include_diff || $self->file_stats ) {                  if ( $self->include_diff || $self->file_stats ) {
119                          my $rev = $e->{'revision'};                          my $rev = $e->{'revision'};
                         my $file = $svn_path;  
                         $file =~ s{^\w+:/+}{};  
                         my $file = "var/svn/$file/$rev.diff";  
                         my $diff = $self->load( $file );  
                         if ( ! $diff ) {  
                                 $diff = `svn diff -c $rev $svn_path`;  
                                 $self->store( $file, $diff );  
                         }  
   
                         $e->{diff} .= $diff if $self->include_diff;  
120    
121                          $e->{diff_paths}->{rev} = $rev; # XXX debug                          $e->{diff_paths}->{rev} = $rev; # XXX debug
122    
123                            my $diff_file = $svn_path;
124                            $diff_file =~ s{^\w+:/+}{};
125                            mkpath "var/svn/$diff_file" unless -e "var/svn/$diff_file";
126                            $diff_file = "var/svn/$diff_file/$rev.diff";
127                            my $diff_fh;
128                            my $diff_out;
129                            if ( ! -e $diff_file || ! -s $diff_file ) {
130                                    my $cmd = "svn diff -c $rev $svn_path";
131                                    open($diff_fh, '-|', $cmd )  || die "can't open pipe from $cmd: $!";
132                                    open($diff_out,'>' , $diff_file ) || die "can't write $diff_file: $!";
133                                    warn "# creating $diff_file from $cmd\n";
134                            } else {
135                                    open($diff_fh, '<' , $diff_file ) || die "can't read $diff_file: $!";
136                            }
137    
138                          my $diff_path;                          my $diff_path;
139                          foreach my $line ( split(/[\n\r]/, $diff ) ) {  
140                                  if ( $line =~ m{^\+\+\+ (\S+)} ) {                          while( <$diff_fh> ) {
141                                    $e->{diff} .= $_ if $self->include_diff;
142                                    print $diff_out $_ if defined $diff_out;
143    
144                                    if ( m{^\+\+\+ (\S+)} ) {
145                                          $diff_path = "/$1"; # subversion paths start with /                                          $diff_path = "/$1"; # subversion paths start with /
146                                  } elsif ( $line =~ m{^\+} ) {                                  } elsif ( m{^\+} && $diff_path ) {
147                                          $e->{diff_paths}->{$diff_path}->{added}++;                                          $e->{diff_paths}->{$diff_path}->{added}++;
148                                  } elsif ( $line =~ m{^-} ) {                                  } elsif ( m{^-} && $diff_path ) {
149                                          $e->{diff_paths}->{$diff_path}->{removed}++;                                          $e->{diff_paths}->{$diff_path}->{removed}++;
150                                  }                                  }
151                          }                          }
# Line 292  sub codeswarm_as_markup { Line 302  sub codeswarm_as_markup {
302                  foreach my $p (@{$e->{'paths'}->{'path'}}) {                  foreach my $p (@{$e->{'paths'}->{'path'}}) {
303                          my ($action,$path) = ($p->{'action'},$p->{'content'});                          my ($action,$path) = ($p->{'action'},$p->{'content'});
304                          my $weight = '';                          my $weight = '';
305                          if ( defined   $e->{diff_paths}->{$path} ) {                          if ( my $s = $e->{diff_paths}->{$path} ) {
306                                  $weight  = $e->{diff_paths}->{$path}->{removed};                                  $weight  = $s->{removed}   if $s->{removed};
307                                  $weight += $e->{diff_paths}->{$path}->{added} * 2;                                  $weight += $s->{added} * 2 if $s->{added};
308                                  $weight  = qq| weight="$weight" |;                                  $weight  = qq| weight="$weight" |;
309                          }                          }
310                          $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|;

Legend:
Removed from v.1067  
changed lines
  Added in v.1068

  ViewVC Help
Powered by ViewVC 1.1.26