6 |
|
|
7 |
use Moose::Util::TypeConstraints; |
use Moose::Util::TypeConstraints; |
8 |
|
|
9 |
enum 'SVK_Action' => ( 'commit', 'revert' ); |
enum 'SVK_Action' => ( 'commit', 'revert', 'postpone' ); |
10 |
|
|
11 |
has action => ( |
has action => ( |
12 |
is => 'rw', |
is => 'rw', |
106 |
$self->add_css( qq| |
$self->add_css( qq| |
107 |
pre span.add { background: #dfd } |
pre span.add { background: #dfd } |
108 |
pre span.del { background: #fdd } |
pre span.del { background: #fdd } |
109 |
pre form.revert { display: inline } |
pre form.inline { display: inline } |
110 |
| ); |
| ); |
111 |
$diff =~ s{^(\+.+?)$}{<span class="add">$1</span>}gm; |
$diff =~ s{^(\+.+?)$}{<span class="add">$1</span>}gm; |
112 |
$diff =~ s{^(\-.+?)$}{<span class="del">$1</span>}gm; |
$diff =~ s{^(\-.+?)$}{<span class="del">$1</span>}gm; |
113 |
$diff =~ s{^(===\s+)(\S+)$}{$1<form class="revert"><input type="hidden" name="path" value="$2"><input type="submit" name="action" value="revert"></form> <a name="$2" target="editor" href="/editor+$2+1">$2</a>}gm; |
sub form { |
114 |
|
my ( $path, $action ) = @_; |
115 |
|
qq|<form class="inline"><input type="hidden" name="path" value="$path"><input type="submit" name="action" value="$action"></form>|; |
116 |
|
}; |
117 |
|
$diff =~ s{^(===\s+)(\S+)$}{$1 . form($2,'revert') . qq| <a name="$2" target="editor" href="/editor+$2+1">$2</a> | . form($2,'postpone') }gem; |
118 |
|
|
119 |
$diff = qq|<pre>$diff</pre>|; |
$diff = qq|<pre>$diff</pre>|; |
120 |
warn "diff_as_markup ",length($diff)," bytes"; |
warn "diff_as_markup ",length($diff)," bytes"; |
125 |
my ($self) = @_; |
my ($self) = @_; |
126 |
|
|
127 |
my $html = ''; |
my $html = ''; |
128 |
|
my $cmd; |
129 |
|
|
130 |
if ( $self->action ) { |
if ( $self->action eq 'postpone' ) { |
131 |
|
my $old = $self->path; |
132 |
|
my $new = $old . '.postponed'; |
133 |
|
die "Allready have $new" if -e $new; |
134 |
|
$cmd = "mv $old $new && svk revert $old"; |
135 |
|
} elsif ( $self->action ) { |
136 |
my $cmd = 'svk ' . $self->action . ' ' . $self->path; |
my $cmd = 'svk ' . $self->action . ' ' . $self->path; |
137 |
if ( $self->action eq 'commit' ) { |
if ( $self->action eq 'commit' ) { |
138 |
confess "need commit message" unless $self->commit_message; |
confess "need commit message" unless $self->commit_message; |
142 |
} else { |
} else { |
143 |
confess "need path" unless $self->path; |
confess "need path" unless $self->path; |
144 |
} |
} |
145 |
|
} |
146 |
|
if ( $cmd ) { |
147 |
$cmd .= ' 2>&1'; |
$cmd .= ' 2>&1'; |
148 |
my $out = `$cmd`; |
my $out = `$cmd`; |
149 |
warn "$cmd $out"; |
warn "$cmd $out"; |
150 |
|
|
151 |
$html .= qq| |
$html .= qq| |
152 |
<code style="background: #ff8;"> |
<code style="background: #ff8;"> |
153 |
$cmd\n |
$cmd\n |