/[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 1077 by dpavlin, Wed Jun 3 18:19:03 2009 UTC revision 1078 by dpavlin, Thu Jun 4 19:23:32 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 124  sub iterator { Line 126  sub iterator {
126                          $cache =~ s{^\w+:/+}{};                          $cache =~ s{^\w+:/+}{};
127                          $cache = "var/svn/$cache";                          $cache = "var/svn/$cache";
128                          mkpath $cache unless -e $cache;                          mkpath $cache unless -e $cache;
129                          my $diff_paths = $self->load( "$cache/$rev.yaml" );  
130                          if ( ! $diff_paths ) {                          my $diff_path = "$cache/$rev.diff";
131                            $e->{diff} = $self->load( $diff_path ) if $self->include_diff && -e $diff_path;
132    
133                            my $diff_yaml = "$cache/$rev.yaml";
134    
135                            if ( -e $diff_yaml ) {
136                                    $e->{diff_paths} = $self->load( $diff_yaml );
137                            } else {
138                                  my $cmd = "svn diff -c $rev $svn_path";                                  my $cmd = "svn diff -c $rev $svn_path";
139                                  my ( $diff_fh, $diff_out );                                  my ( $diff_fh, $diff_out );
140                                  my $diff_file = "$cache/$rev.diff";                                  my $diff_file = "$cache/$rev.diff";
141    
142                                  open($diff_fh, '-|', $cmd)       || die "can't open pipe from $cmd: $!";                                  open($diff_fh, '-|', $cmd)       || die "can't open pipe from $cmd: $!";
143                                  open($diff_out,'>' , $diff_file) || die "can't write $diff_file: $!";                                  open($diff_out,'>' , $diff_file) || die "can't write $diff_file: $!";
144                                  warn "# creating $diff_file from $cmd\n";                                  #warn "# creating $diff_file from $cmd\n";
145    
146                                  my $diff_path;                                  my $diff_path;
147                                    my $changes;
148                                    my $diff = '';
149    
150                                  while( <$diff_fh> ) {                                  while( <$diff_fh> ) {
151                                            $diff .= $_;
152                                          print $diff_out $_;                                          print $diff_out $_;
153    
154                                          if ( m{^\+\+\+ (\S+)} ) {                                          if ( m{^\+\+\+ (\S+)} ) {
155                                                  $diff_path = "/$1"; # subversion paths start with /                                                  $diff_path = "/$1"; # subversion paths start with /
156                                          } elsif ( m{^\+} && $diff_path ) {                                          } elsif ( m{^\+} && $diff_path ) {
157                                                  $diff_paths->{$diff_path}->{added}++;                                                  $changes->{$diff_path}->{added}++;
158                                          } elsif ( m{^-} && $diff_path ) {                                          } elsif ( m{^-} && $diff_path ) {
159                                                  $diff_paths->{$diff_path}->{removed}++;                                                  $changes->{$diff_path}->{removed}++;
160                                          }                                          }
161                                  }                                  }
162    
163                                  $self->store( "$cache/$rev.yaml", $diff_paths );                                  $e->{diff} = $diff if $self->include_diff;
164    
165                                    $self->store( "$cache/$rev.yaml", $changes );
166                                    $e->{diff_paths} = $changes;
167                          }                          }
168                          $e->{diff}       = $self->load( "$cache/$rev.diff" ) if $self->include_diff;          
                         $e->{diff_paths} = $self->load( "$cache/$rev.yaml" );  
169                  }                  }
170    
171                  $coderef->($e);                  $coderef->($e);

Legend:
Removed from v.1077  
changed lines
  Added in v.1078

  ViewVC Help
Powered by ViewVC 1.1.26