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

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

  ViewVC Help
Powered by ViewVC 1.1.26