/[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 1073 by dpavlin, Tue Apr 28 22:36:26 2009 UTC revision 1084 by dpavlin, Tue Jun 23 17:35:08 2009 UTC
# Line 110  sub iterator { Line 110  sub iterator {
110          }          }
111          close($fh);          close($fh);
112    
113            warn "got ", length($log), " bytes of XML changes\n";
114    
115          my $xml = XMLin($log, ForceArray => [ 'logentry', 'path' ]);          my $xml = XMLin($log, ForceArray => [ 'logentry', 'path' ]);
116    
117          foreach my $e (@{$xml->{'logentry'}}) {          foreach my $e (@{$xml->{'logentry'}}) {
# Line 118  sub iterator { Line 120  sub iterator {
120                  if ( $self->include_diff || $self->file_stats ) {                  if ( $self->include_diff || $self->file_stats ) {
121                          my $rev = $e->{'revision'};                          my $rev = $e->{'revision'};
122    
123                            warn "# revision $rev\n" if $rev % 100 == 0;
124    
125                          $e->{diff_paths}->{rev} = $rev; # XXX debug                          $e->{diff_paths}->{rev} = $rev; # XXX debug
126    
127                          my $cache = $svn_path;                          my $cache = $svn_path;
128                          $cache =~ s{^\w+:/+}{};                          $cache =~ s{^\w+:/+}{};
129                          $cache = "var/svn/$cache";                          $cache = "var/svn/$cache";
130                          mkpath $cache unless -e $cache;                          mkpath $cache unless -e $cache;
131                          my $diff_paths = $self->load( "$cache/$rev.yaml" );  
132                          if ( ! $diff_paths ) {                          my $diff_path = "$cache/$rev.diff";
133                            $e->{diff} = $self->load( $diff_path ) if $self->include_diff && -e $diff_path;
134    
135                            my $diff_yaml = "$cache/$rev.yaml";
136    
137                            if ( -e $diff_yaml ) {
138                                    $e->{diff_paths} = $self->load( $diff_yaml );
139                            } else {
140                                  my $cmd = "svn diff -c $rev $svn_path";                                  my $cmd = "svn diff -c $rev $svn_path";
141                                  my ( $diff_fh, $diff_out );                                  my ( $diff_fh, $diff_out );
142                                  my $diff_file = "$cache/$rev.diff";                                  my $diff_file = "$cache/$rev.diff";
143    
144                                  open($diff_fh, '-|', $cmd)       || die "can't open pipe from $cmd: $!";                                  open($diff_fh, '-|', $cmd)       || die "can't open pipe from $cmd: $!";
145                                  open($diff_out,'>' , $diff_file) || die "can't write $diff_file: $!";                                  open($diff_out,'>' , $diff_file) || die "can't write $diff_file: $!";
146                                  warn "# creating $diff_file from $cmd\n";                                  #warn "# creating $diff_file from $cmd\n";
147    
148                                  my $diff_path;                                  my $diff_path;
149                                    my $changes;
150                                    my $diff = '';
151    
152                                  while( <$diff_fh> ) {                                  while( <$diff_fh> ) {
153                                            $diff .= $_;
154                                          print $diff_out $_;                                          print $diff_out $_;
155    
156                                          if ( m{^\+\+\+ (\S+)} ) {                                          if ( m{^\+\+\+ (\S+)} ) {
157                                                  $diff_path = "/$1"; # subversion paths start with /                                                  $diff_path = "/$1"; # subversion paths start with /
158                                          } elsif ( m{^\+} && $diff_path ) {                                          } elsif ( m{^\+} && $diff_path ) {
159                                                  $diff_paths->{$diff_path}->{added}++;                                                  $changes->{$diff_path}->{added}++;
160                                          } elsif ( m{^-} && $diff_path ) {                                          } elsif ( m{^-} && $diff_path ) {
161                                                  $diff_paths->{$diff_path}->{removed}++;                                                  $changes->{$diff_path}->{removed}++;
162                                          }                                          }
163                                  }                                  }
164    
165                                  $self->store( "$cache/$rev.yaml", $diff_paths );                                  $e->{diff} = $diff if $self->include_diff;
166    
167                                    $self->store( "$cache/$rev.yaml", $changes );
168                                    $e->{diff_paths} = $changes;
169                          }                          }
170                          $e->{diff}       = $self->load( "$cache/$rev.diff" ) if $self->include_diff;          
                         $e->{diff_paths} = $self->load( "$cache/$rev.yaml" );  
171                  }                  }
172    
173                  $coderef->($e);                  $coderef->($e);
# Line 313  sub as_markup { Line 329  sub as_markup {
329                  + length( $stats->{total_removed} )                  + length( $stats->{total_removed} )
330                  ;                  ;
331    
332          $max_path_len += int( $max_path_len / 10 ); # we are using ex, so we add 10%          $max_path_len += int( $max_path_len / 4 ); # we are using ex, so we adjust length
333    
334          $self->add_css(qq|          $self->add_css(qq|
335                  .files {                  .files {
# Line 346  sub codeswarm_as_markup { Line 362  sub codeswarm_as_markup {
362                          my ($action,$path) = ($p->{'action'},$p->{'content'});                          my ($action,$path) = ($p->{'action'},$p->{'content'});
363                          my $weight = '';                          my $weight = '';
364                          if ( my $s = $e->{diff_paths}->{$path} ) {                          if ( my $s = $e->{diff_paths}->{$path} ) {
365                                  $weight  = $s->{removed}   if defined $s->{removed};                                  $weight  = $s->{removed} || 0;
366                                  $weight += $s->{added} * 2 if defined $s->{added};                                  $weight += $s->{added} * 2 if $s->{added};
367                                  $weight  = qq| weight="$weight" |;                                  $weight  = qq| weight="$weight" |;
368                          }                          }
369                          $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|;
# Line 355  sub codeswarm_as_markup { Line 371  sub codeswarm_as_markup {
371    
372          });          });
373    
374            warn "generated ",length($file_events)," bytes of file events\n";
375    
376          return qq|<?xml version="1.0"?>          return qq|<?xml version="1.0"?>
377          <!-- One commit per day for one month by a documenter and programmer. -->          <!-- One commit per day for one month by a documenter and programmer. -->
378          <file_events>          <file_events>

Legend:
Removed from v.1073  
changed lines
  Added in v.1084

  ViewVC Help
Powered by ViewVC 1.1.26