/[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

Contents of /trunk/lib/Frey/SVK.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 505 - (show annotations)
Mon Nov 24 22:21:02 2008 UTC (15 years, 5 months ago) by dpavlin
File size: 973 byte(s)
show svk commit number along with version
1 package Frey::SVK;
2 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 {
17 my ($self) = @_;
18 my @modified;
19 my $svk = $self->svk('status -q', sub {
20 push @modified, $1 if /^M\s+(.+)/;
21 });
22 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 {
37 my ($self) = @_;
38 {
39 modified => [ $self->modified ],
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;

  ViewVC Help
Powered by ViewVC 1.1.26