--- trunk/lib/Frey/SVK.pm 2008/12/02 18:12:38 684 +++ branches/no-pager/lib/Frey/SVK.pm 2008/12/06 15:29:10 738 @@ -17,7 +17,7 @@ has path => ( documentation => 'path to work with', is => 'rw', - isa => 'Str', + isa => 'Str|ArrayRef', ); has commit_message => ( @@ -67,18 +67,23 @@ sub commit_as_markup { my ($self) = @_; my $status = `svk status -q`; - $status =~ s{^(\w+[\+\s]+)(\S+)$}{$1$2}gm; # FIXME -# $status =~ s{^(\w+[\+\s]+)(\S+)$}{$1$2}gm; + $status =~ s{^(\w+[\+\s]+)(\S+)$}{$1 . $self->checkbox('path',$2) . qq|$2|}egm; if ( $status ) { $self->add_css(qq| pre.l a { text-decoration: none; } form.commit { - background: #ffd; + background: #eee; padding: 1em 1em; position: fixed; top: 1em; right: 1em; z-index: 10; + opacity: .2; + filter: alpha(opacity=20); + } + form.commit:hover { + opacity: 1; + filter: alpha(opacity=100); } | ); @@ -112,19 +117,18 @@ $diff =~ s{^(\-.+?)$}{$1}gm; sub form { my ( $path, $action ) = @_; - qq|
|; + qq|
|; }; $diff =~ s{^(===\s+)(\S+)$}{$1 . form($2,'revert') . qq| $2 | . form($2,'postpone') }gem; - $diff = qq|
$diff
|; + $diff = qq|
$diff
| if $diff; warn "diff_as_markup ",length($diff)," bytes"; return $diff; } -sub as_markup { +sub action_as_markup { my ($self) = @_; - my $html = ''; my $cmd; if ( $self->action eq 'postpone' ) { @@ -137,31 +141,43 @@ } elsif ( $self->action ) { $cmd = 'svk ' . $self->action; if ( $self->action eq 'commit' ) { - my $msg = $self->commit_message || confess "need commit message"; + my $msg = $self->commit_message || return $self->error( "need commit message\n" ); $msg =~ s{"}{\\"}gs; $cmd .= qq{ -m "$msg"}; - } elsif ( my $path = $self->path ) { - $cmd .= " $path"; } else { confess "need path" unless $self->path; } + + my @paths = eval { @{ $self->path } }; # XXX sigh! + @paths = ( $self->path ) unless @paths; + warn "# path ", $self->dump( @paths ); + + $cmd .= ' ' . join( ' ',@paths ); } if ( $cmd ) { $cmd .= ' 2>&1'; + warn "# cmd $cmd"; + my $out = `$cmd`; - warn "$cmd $out"; + warn "# output of $cmd is: $out"; - $html .= qq| - - $cmd\n - $out - + return qq| + Command $cmd produced output: +
$out
|; } +} + +sub as_markup { + my ($self) = @_; + + my $html = $self->action_as_markup; + $self->title( 'svk' . ( $self->action ? ' - ' . $self->action : '' ) ); # XXX without this we get wrong icon and title - $html .= $self->commit_as_markup . $self->diff_as_markup; + $html .= $self->commit_as_markup . $self->diff_as_markup || + qq|No changes in tracked files|; warn "as_markup ",length($html)," bytes";