[Bps-public-commit] r9102 - in SVKUI: . trunk/lib trunk/lib/SVKUI/View trunk/share/web/templates/project

clsung at bestpractical.com clsung at bestpractical.com
Thu Sep 20 11:09:45 EDT 2007


Author: clsung
Date: Thu Sep 20 11:09:43 2007
New Revision: 9102

Modified:
   SVKUI/   (props changed)
   SVKUI/trunk/lib/SVKUI.pm
   SVKUI/trunk/lib/SVKUI/View.pm
   SVKUI/trunk/lib/SVKUI/View/browse.pm
   SVKUI/trunk/share/web/templates/project/index.html

Log:
 r9180 at going04:  clsung | 2007-09-20 16:31:07 +0800
 - list path changed.
 r9181 at going04:  clsung | 2007-09-20 16:52:42 +0800
 - add support for 'svk log'
 r9182 at going04:  clsung | 2007-09-20 16:58:52 +0800
 - typo, and implementation for 'log'
 r9183 at going04:  clsung | 2007-09-20 17:02:10 +0800
 - call Jifty::View::Declare::Handler->template_exists
 r9184 at going04:  clsung | 2007-09-20 17:20:24 +0800
 - fix problem when passing arugment"s" into SVK::Command
 r9185 at going04:  clsung | 2007-09-20 23:09:29 +0800
 - 'cross' is required by log, too


Modified: SVKUI/trunk/lib/SVKUI.pm
==============================================================================
--- SVKUI/trunk/lib/SVKUI.pm	(original)
+++ SVKUI/trunk/lib/SVKUI.pm	Thu Sep 20 11:09:43 2007
@@ -11,6 +11,7 @@
 
 sub svk {
     my $class = shift;
+    warn "svk exists" if $class->_svk;
     return $class->_svk if $class->_svk;
     my $depotmap = { '' => Jifty->config->app('repos') };
     my $svkpath = Jifty->config->app('svkpath');
@@ -22,6 +23,7 @@
     $class->load_mirror($xd);
     my $svk = SVK->new (xd => $xd);
     $svk->depotmap ('--init');
+    warn "New svk";
     return $class->_svk( $svk );
 }
 

Modified: SVKUI/trunk/lib/SVKUI/View.pm
==============================================================================
--- SVKUI/trunk/lib/SVKUI/View.pm	(original)
+++ SVKUI/trunk/lib/SVKUI/View.pm	Thu Sep 20 11:09:43 2007
@@ -160,83 +160,9 @@
 #        show ('error/failed');
 	show '/__jifty/error/command_failed';
     } else {
-    
-	if ($cmd eq 'list') {
-	    h2 { ('Output of '.$cmd.' in '.$mirror->name.' project') };
-	    my @relpaths = split /\n/, $command->output_raw;
-#	    div { { id is 'jumprev' }
-#		div {
-#		    label { 'Go To' }
-#		}
-#	    };
-	    table { {class is 'listing' } { id is 'dirlist' } {summary is 'Browse Listing'} 
-		thead { 
-		    row {
-			th { {class is 'name' } 'Name' }
-			th { {class is 'rev' } 'Revision' }
-			th { {class is 'size' } 'Size' }
-			th { {class is 'age' } 'Age' }
-			th { {class is 'change' } 'Last Change' }
-		    }
-		}
-		tbody {
-		for my $_relpath (@relpaths) {
-		    my (undef, $_rev, $_last, $_size, $_mon, $_day, $_time, $_name) = split / {1,12}/, $_relpath;
-		    row {
-			if ($_relpath =~ m#/$#m) {
-			cell { {class is 'name'}
-			Jifty->web->link (url => '/ia2/'.$mirror->name."/list?args=-v&path=$relpath/$_name", label => $_name, class => 'dir');
-			};
-			} else {
-			cell {
-			Jifty->web->link (url => '/ia2/'.$mirror->name."/annotate?path=$relpath/$_name", label => $_name, class => 'file');
-			};
-			}
-			cell { {class is 'rev'} $_rev };
-			cell { {class is 'size'} $_size };
-			cell { {class is 'age'} 'N/A' };
-			cell { {class is 'change'} $_last };
-		    }
-		}
-	    };
-	    };
-	} elsif ($cmd eq 'annotate') {
-	    my @lines = split /\n/, $command->output_raw;
-	    my $last_rev = -1;
-	    my $line_no = 0;
-	    my @styles = ( '#e0e0e0', '#f7f7f7' );
-	    my $index_style = 0;
-	    table { {class is 'listing' } { id is 'dirlist' } {summary is 'Browse Listing'} 
-		thead { 
-		    row {
-			th { 'Line #' }
-			th { {class is 'chgset' } 'Revision' }
-			th { {class is 'author' } 'Author' }
-			th {}
-		    }
-		}
-		tbody {
-		for my $_line (@lines) {
-		    warn $_line;
-		    my ($_rev, $_author, $_time, $_content) = ($_line =~ m/^ *(\d+)\t+\( *(\w+) ([\d-]+)\):\t+(.*)$/);
-		    next unless defined ($_rev);
-		    $index_style = ($index_style + 1) % 2 if ($last_rev != $_rev);
-		    row {
-			cell { $line_no };
-			cell { {class is 'chgset'} $_rev if ($last_rev != $_rev) };
-			cell { {class is 'author', align is 'center'} $_author };
-			cell { {style is "white-space: pre; background: $styles[$index_style];" } $_content }
-		    }
-		    $line_no++;
-		    $last_rev = $_rev;
-		}
-	    };
-	    };
-	} else {
-	    dl {
-		pre { outs($command->output_raw) };
-	    };
-	}
+	dl {
+	    pre { outs($command->output_raw) };
+	};
     }
 };
 
@@ -276,9 +202,10 @@
     my $proj_name = get('proj_name');
     my $cmd = get('command') || 'list';
     my $relpath = get ('path') || '';
+    my $rev = get ('rev') || '';
     my $proj = SVKUI::Model::Project->new();
     $proj->load_by_cols( name => $proj_name );
-    if (!$proj->id or ($cmd ne 'list' and $cmd ne 'annotate')) {  # project record not found
+    if (!$proj->id or (!Jifty::View::Declare::Handler->template_exists('browse/'.$cmd))) {  # project record not found
         redirect '/';
     }
 
@@ -286,13 +213,14 @@
     my $ret;
 
     my $rootpath = Jifty->config->app('checkoutroot')."/".$proj->name;
-    my $args = $cmd eq 'list' ? '-v' : '-x';
-    $ret = $command->cmd($cmd, $args, $rootpath.'/'.$relpath);
+    my @args = $cmd eq 'annotate' ? ('-x') : ('-v');
+    push @args ,"-r",$rev, '-x' if $rev ne '';
+    $ret = $command->cmd($cmd, @args, $rootpath.'/'.$relpath);
     if ($ret) {
 	set proj => $proj;
 	show '/__jifty/error/command_failed';
     } else {
-	set ( output_raw => $command->output_raw, proj_name => $proj_name, relpath => $relpath );
+	set ( output_raw => $command->output_raw, proj_name => $proj_name, relpath => $relpath, rev => $rev );
 	show ('browse/'.$cmd);
     }
 };

Modified: SVKUI/trunk/lib/SVKUI/View/browse.pm
==============================================================================
--- SVKUI/trunk/lib/SVKUI/View/browse.pm	(original)
+++ SVKUI/trunk/lib/SVKUI/View/browse.pm	Thu Sep 20 11:09:43 2007
@@ -41,7 +41,6 @@
 
 template list => sub {
     my $self = shift;
-    warn "hihihi";
     my $proj_name = get('proj_name');
     my $relpath = get('relpath');
     my $output_raw = get('output_raw');
@@ -71,7 +70,10 @@
 			label => $_name, class => 'file');
 		};
 		}
-		cell { {class is 'rev'} $_rev };
+		cell { {class is 'rev'} 
+		    Jifty->web->link (url => '/browse/'.$proj_name."/log?path=$relpath/$_name&rev=$_rev", 
+			label => $_rev, class => 'file');
+		};
 		cell { {class is 'size'} $_size };
 		cell { {class is 'age'} 'N/A' };
 		cell { {class is 'change'} $_last };
@@ -81,4 +83,39 @@
     };
 };
 
+template log => sub {
+    my $self = shift;
+    my $output_raw = get('output_raw');
+    my @lines = split /\n/, $output_raw;
+    my $last_rev = -1;
+    my $line_no = 0;
+    my @styles = ( '#e0e0e0', '#f7f7f7' );
+    my $index_style = 0;
+    table { {class is 'listing' } { id is 'dirlist' } {summary is 'Browse Listing'} 
+	thead { 
+	    row {
+		th { 'Line #' }
+		th { {class is 'chgset' } 'Revision' }
+		th { {class is 'author' } 'Author' }
+		th {}
+	    }
+	}
+	tbody {
+	for my $_line (@lines) {
+	    my ($_rev, $_author, $_time, $_content) = ($_line =~ m/^ *(\d+)\t+\( *(\w+) ([\d-]+)\):\t+(.*)$/);
+	    next unless defined ($_rev);
+	    $index_style = ($index_style + 1) % 2 if ($last_rev != $_rev);
+	    row {
+		cell { $line_no };
+		cell { {class is 'chgset'} $_rev if ($last_rev != $_rev) };
+		cell { {class is 'author', align is 'center'} $_author };
+		cell { {style is "white-space: pre; background: $styles[$index_style];" } $_content }
+	    }
+	    $line_no++;
+	    $last_rev = $_rev;
+	} # for
+	};
+    };
+};
+
 1;

Modified: SVKUI/trunk/share/web/templates/project/index.html
==============================================================================
--- SVKUI/trunk/share/web/templates/project/index.html	(original)
+++ SVKUI/trunk/share/web/templates/project/index.html	Thu Sep 20 11:09:43 2007
@@ -56,7 +56,7 @@
 % } else {
 <% $mirror->revision %>
 <h4>Browse checkout-ed files</h4>
-<%Jifty->web->link( url => '/ia2/'.$mirror->name.'/list', label => 'List')%>
+<%Jifty->web->link( url => '/browse/'.$mirror->name, label => 'List')%>
 % }
 
 </div>



More information about the Bps-public-commit mailing list