--- trunk/lib/Frey/SVK.pm 2008/11/27 15:40:12 552 +++ trunk/lib/Frey/SVK.pm 2008/11/28 16:39:37 591 @@ -4,6 +4,18 @@ extends 'Frey'; with 'Frey::Web'; +has commit_path => ( + documentation => 'path to commit', + is => 'rw', + isa => 'Str', +); + +has message => ( + documentation => 'commit message', + is => 'rw', + isa => 'Str', +); + sub svk { my ( $self, $exec, $coderef ) = @_; open(my $svk, '-|', 'svk ' . $exec) or die "svk $exec: $@"; @@ -18,7 +30,7 @@ my ($self) = @_; my @modified; my $svk = $self->svk('status -q', sub { - push @modified, $1 if /^(M|A)\s+(.+)/; + push @modified, $1 if /^\w+\s+(.+)/; }); return @modified; } @@ -31,6 +43,7 @@ my ( $label, $value ) = split(/:\s+/, $_, 2); $info->{$label} = $value if $label; }); + warn "# svk info ",$self->dump( $info ); return $info; } @@ -41,20 +54,46 @@ } } -sub as_markup { +sub status_as_markup { my ($self) = @_; - my $status = `svk status -q`; + $status =~ s{^(\w+\s+)(\S+)$}{$1$2}gm; + $self->add_css( qq| pre.l a { text-decoration: none; } | ); + $status = qq|
$status
|; + $self->add_status( $status ); + warn "status_as_markup ",length($status)," bytes"; + return $status; +} + +sub diff_as_markup { + my ($self) = @_; + my $diff = `svk diff`; - Frey::Web->meta->apply( $self ); # provide html_escape + $diff = $self->html_escape( $diff ); + $self->add_css( qq| + pre span.add { background: #dfd } + pre span.del { background: #fdd } + | ); + $diff =~ s{^(\+.+?)$}{$1}gm; + $diff =~ s{^(\-.+?)$}{$1}gm; + $diff =~ s{^(===\s+)(\S+)$}{$1$2}gm; + + $diff = qq|
$diff
|; + warn "diff_as_markup ",length($diff)," bytes"; + return $diff; +} + +sub as_markup { + my ($self) = @_; + + if ( ! $self->can('html_escape') ) { + Frey::Web->meta->apply( $self ); + $self->TODO( "Frey::Web role missing" ); + } - my $html - = qq|
$status

|
-		. $self->html_escape( $diff )
-		. qq|
| - ; - warn "diff ",length($html)," bytes"; + my $html = $self->status_as_markup . $self->diff_as_markup; + warn "as_markup ",length($html)," bytes"; return $html; }