/[Frey]/trunk/lib/Frey/SVK.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/SVK.pm

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

revision 485 by dpavlin, Mon Nov 24 15:33:00 2008 UTC revision 552 by dpavlin, Thu Nov 27 15:40:12 2008 UTC
# Line 1  Line 1 
1  package Frey::SVK;  package Frey::SVK;
2  use Moose;  use Moose;
3    
4  sub modified {  extends 'Frey';
5          my ($self) = @_;  with 'Frey::Web';
6          my @modified;  
7          open(my $svk, '-|', 'svk status -q') or die $@;  sub svk {
8            my ( $self, $exec, $coderef ) = @_;
9            open(my $svk, '-|', 'svk ' . $exec) or die "svk $exec: $@";
10          while(<$svk>) {          while(<$svk>) {
11                  chomp;                  chomp;
12                  push @modified, $1 if /^M\s+(.+)/;                  $coderef->( $_ );
13          }          }
14            close($svk) or die "can't close svk $exec: $@";
15    }
16    
17    sub modified {
18            my ($self) = @_;
19            my @modified;
20            my $svk = $self->svk('status -q', sub {
21                    push @modified, $1 if /^(M|A)\s+(.+)/;
22            });
23          return @modified;          return @modified;
24  }  }
25    
26    our $info; # cache, we use it on every hit
27    sub info {
28            my ($self) = @_;
29            return $info if $info;
30            my $svk = $self->svk('info', sub {
31                    my ( $label, $value ) = split(/:\s+/, $_, 2);
32                    $info->{$label} = $value if $label;
33            });
34            return $info;
35    }
36    
37  sub as_data {  sub as_data {
38          my ($self) = @_;          my ($self) = @_;
39          {          {
# Line 19  sub as_data { Line 41  sub as_data {
41          }          }
42  }  }
43    
44    sub as_markup {
45            my ($self) = @_;
46    
47            my $status = `svk status -q`;
48            my $diff   = `svk diff`;
49    
50            Frey::Web->meta->apply( $self ); # provide html_escape
51    
52            my $html
53                    = qq|<pre>$status</pre><hr><pre>|
54                    . $self->html_escape( $diff )
55                    . qq|</pre>|
56                    ;
57            warn "diff ",length($html)," bytes";
58    
59            return $html;
60    }
61    
62  1;  1;

Legend:
Removed from v.485  
changed lines
  Added in v.552

  ViewVC Help
Powered by ViewVC 1.1.26