--- trunk/lib/Frey/SVK.pm 2008/12/02 22:05:25 690 +++ trunk/lib/Frey/SVK.pm 2008/12/15 18:57:29 848 @@ -36,11 +36,13 @@ close($svk) or die "can't close svk $exec: $@"; } +our $svk_status_path = '^(\w+[\+\s]+)(.+)'; + sub modified { my ($self) = @_; my @modified; my $svk = $self->svk('status -q', sub { - push @modified, $1 if /^\w+\s+(.+)/; + push @modified, $2 if m{$svk_status_path}; }); return @modified; } @@ -64,20 +66,10 @@ } } -sub checkbox { - my ($self,$name,$value) = @_; - my $checked = ''; - my $all_checkboxes = $self->$name; - $all_checkboxes = [ $all_checkboxes ] unless ref($all_checkboxes) eq 'ARRAY'; # sigh, too chatty - $checked = ' checked' if grep { $_ eq $value } @$all_checkboxes; - warn "# checkbox $name $value $checked\t", $self->dump( $self->$name ); - qq||; -} - sub commit_as_markup { my ($self) = @_; my $status = `svk status -q`; - $status =~ s{^(\w+[\+\s]+)(\S+)$}{$1 . $self->checkbox('path',$2) . qq|$2|}egm; + $status =~ s{$svk_status_path}{$1 . $self->checkbox('path',$2) . qq|$2|}egm; if ( $status ) { $self->add_css(qq| pre.l a { text-decoration: none; } @@ -88,6 +80,12 @@ top: 1em; right: 1em; z-index: 10; + opacity: .2; + filter: alpha(opacity=20); + } + form.commit:hover { + opacity: 1; + filter: alpha(opacity=100); } | ); @@ -113,19 +111,24 @@ $diff = $self->html_escape( $diff ); $self->add_css( qq| + pre span.add, + pre span.del { + float: left; + width: 100%; + } pre span.add { background: #dfd } pre span.del { background: #fdd } pre form.inline { display: inline } | ); - $diff =~ s{^(\+.+?)$}{$1}gm; - $diff =~ s{^(\-.+?)$}{$1}gm; + $diff =~ s{^(\+.*?)$}{$1}gm; + $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; } @@ -151,7 +154,12 @@ } else { confess "need path" unless $self->path; } - $cmd .= ' ' . join(' ',$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'; @@ -162,9 +170,8 @@ return qq| Command $cmd produced output: - - $out - +
$out
+ reload page to prevent this post from triggering again
|; } @@ -177,7 +184,8 @@ $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";