--- trunk/lib/Frey/SVK.pm 2008/11/29 00:20:23 614 +++ trunk/lib/Frey/SVK.pm 2008/11/29 01:01:14 615 @@ -4,16 +4,19 @@ extends 'Frey'; with 'Frey::Web'; -has commit_path => ( - documentation => 'path to commit', +use Moose::Util::TypeConstraints; + +enum 'SVK_Action' => ( 'commit', 'revert' ); + +has action => ( is => 'rw', - isa => 'ArrayRef|Str', + isa => 'SVK_Action', ); -has revert_path => ( - documentation => 'path to commit', +has path => ( + documentation => 'path to work with', is => 'rw', - isa => 'ArrayRef|Str', + isa => 'Str', ); has message => ( @@ -63,19 +66,32 @@ sub status_as_markup { my ($self) = @_; my $status = `svk status -q`; - $status =~ s{^(\w+\s+)(\S+)$}{$1$2}gm; +# $status =~ s{^(\w+\s+)(\S+)$}{$1$2}gm; # FIXME + $status =~ s{^(\w+\s+)(\S+)$}{$1$2}gm; if ( $status ) { - $self->add_css( qq| pre.l a { text-decoration: none; } | ); + $self->add_css(qq| + pre.l a { text-decoration: none; } + div.commit { + background: #ffd; + padding: 1em 1em; + position: fixed; + top: 1em; + right: 1em; + z-index: 10; + } + | ); + $status = qq| -
-
- -
+
+ + +
+
$status
- |; $self->add_status( $status ); + } warn "status_as_markup ",length($status)," bytes"; return $status; @@ -94,7 +110,7 @@ | ); $diff =~ s{^(\+.+?)$}{$1}gm; $diff =~ s{^(\-.+?)$}{$1}gm; - $diff =~ s{^(===\s+)(\S+)$}{$1
$2}gm; + $diff =~ s{^(===\s+)(\S+)$}{$1
$2}gm; $diff = qq|
$diff
|; warn "diff_as_markup ",length($diff)," bytes"; @@ -106,14 +122,28 @@ my $html = ''; - if ( $self->revert_path ) { - my $cmd = 'svk revert ' . join(' ', $self->revert_path ); - my $revert = `$cmd`; - warn "$cmd $revert"; - $html .= qq|$revert|; + if ( $self->action ) { + my $cmd = 'svk ' . $self->action . ' ' . $self->path; + if ( $self->action eq 'commit' ) { + confess "need message" unless $self->message; + my $msg = $self->message; + $msg =~ s{"}{\\"}gs; + $cmd .= qq{ -m "$msg"}; + } else { + confess "need path" unless $self->path; + } + $cmd .= ' 2>&1'; + my $out = `$cmd`; + warn "$cmd $out"; + $html .= qq| + + $cmd\n + $out + + |; } - $self->title('svk'); # XXX without this we get wrong icon and title + $self->title( 'svk' . ( $self->action ? ' - ' . $self->action : '' ) ); # XXX without this we get wrong icon and title if ( ! $self->can('html_escape') ) { Frey::Web->meta->apply( $self );