/[Frey]/trunk/lib/Frey/SVK.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/Frey/SVK.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 615 by dpavlin, Sat Nov 29 01:01:14 2008 UTC revision 653 by dpavlin, Sun Nov 30 23:49:32 2008 UTC
# Line 6  with 'Frey::Web'; Line 6  with 'Frey::Web';
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',
# Line 19  has path => ( Line 19  has path => (
19          isa => 'Str',          isa => 'Str',
20  );  );
21    
22  has message => (  has commit_message => (
23          documentation => 'commit message',          documentation => 'commit message',
24          is => 'rw',          is => 'rw',
25          isa => 'Str',          isa => 'Str',
# Line 67  sub status_as_markup { Line 67  sub status_as_markup {
67          my ($self) = @_;          my ($self) = @_;
68          my $status = `svk status -q`;          my $status = `svk status -q`;
69  #       $status =~ s{^(\w+\s+)(\S+)$}{$1<input name="commit_path" value="$2" type="checkbox"><a href="#$2">$2</a>}gm; # FIXME  #       $status =~ s{^(\w+\s+)(\S+)$}{$1<input name="commit_path" value="$2" type="checkbox"><a href="#$2">$2</a>}gm; # FIXME
70          $status =~ s{^(\w+\s+)(\S+)$}{$1<a href="#$2">$2</a>}gm;          $status =~ s{^(\w+[\+\s]+)(\S+)$}{$1<a href="#$2">$2</a>}gm;
71          if ( $status ) {          if ( $status ) {
72                  $self->add_css(qq|                  $self->add_css(qq|
73                          pre.l a { text-decoration: none; }                          pre.l a { text-decoration: none; }
# Line 82  sub status_as_markup { Line 82  sub status_as_markup {
82                  | );                  | );
83    
84                  $status = qq|                  $status = qq|
85                          <div class="commit">                          <div class="commit" method="post">
86                                  <form>                                  <form>
87                                  <textarea name="message" cols=40 rows=4></textarea>                                  <textarea name="commit_message" cols=40 rows=4></textarea>
88                                  <br><input type="submit" name="action" value="commit">                                  <br><input type="submit" name="action" value="commit">
89                                  </form>                                  </form>
90                          </div>                          </div>
# Line 106  sub diff_as_markup { Line 106  sub diff_as_markup {
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">$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";
# Line 121  sub as_markup { Line 125  sub as_markup {
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 $cmd = 'svk ' . $self->action . ' ' . $self->path;                  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                    $cmd = 'svk ' . $self->action . ' ' . $self->path;
137                  if ( $self->action eq 'commit' ) {                  if ( $self->action eq 'commit' ) {
138                          confess "need message" unless $self->message;                          confess "need commit message" unless $self->commit_message;
139                          my $msg = $self->message;                          my $msg = $self->commit_message;
140                          $msg =~ s{"}{\\"}gs;                          $msg =~ s{"}{\\"}gs;
141                          $cmd .= qq{ -m "$msg"};                          $cmd .= qq{ -m "$msg"};
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
# Line 145  sub as_markup { Line 158  sub as_markup {
158    
159          $self->title( 'svk' . ( $self->action ? ' - ' . $self->action : '' ) ); # 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
160    
161          if ( ! $self->can('html_escape') ) {          $html .= $self->status_as_markup || 'No changes in files tracked by SVK';
162                  Frey::Web->meta->apply( $self );          $html .= $self->diff_as_markup;
                 $self->TODO( "Frey::Web role missing" );  
         }  
   
         $html .= $self->status_as_markup || $self->error('no status_or_markup output');  
         $html .= $self->diff_as_markup   || $self->error('no diff_as_markup output');  
163    
164          warn "as_markup ",length($html)," bytes";          warn "as_markup ",length($html)," bytes";
165    

Legend:
Removed from v.615  
changed lines
  Added in v.653

  ViewVC Help
Powered by ViewVC 1.1.26