[Bps-public-commit] r17769 - in Shipwright/trunk: . bin lib/Shipwright/Backend lib/Shipwright/Script lib/Shipwright/Source t

sunnavy at bestpractical.com sunnavy at bestpractical.com
Fri Jan 16 05:07:07 EST 2009


Author: sunnavy
Date: Fri Jan 16 05:07:06 2009
New Revision: 17769

Modified:
   Shipwright/trunk/   (props changed)
   Shipwright/trunk/bin/shipwright
   Shipwright/trunk/lib/Shipwright/Backend/SVK.pm
   Shipwright/trunk/lib/Shipwright/Backend/SVN.pm
   Shipwright/trunk/lib/Shipwright/Script/List.pm
   Shipwright/trunk/lib/Shipwright/Source/SVK.pm
   Shipwright/trunk/lib/Shipwright/Source/SVN.pm
   Shipwright/trunk/lib/Shipwright/Test.pm
   Shipwright/trunk/t/01.repo_check.t
   Shipwright/trunk/t/71.script_cmds.t

Log:
 r18820 at sunnavys-mb:  sunnavy | 2009-01-16 18:06:39 +0800
 use env SHIPWRIGHT_SVK and SHIPWRIGHT_SVN to get the locations of svk and svn commands. svnadmin is assuming the same location as svn


Modified: Shipwright/trunk/bin/shipwright
==============================================================================
--- Shipwright/trunk/bin/shipwright	(original)
+++ Shipwright/trunk/bin/shipwright	Fri Jan 16 05:07:06 2009
@@ -9,5 +9,7 @@
 local $SIG{INT} = sub { warn "Stopped\n"; exit; };
 
 my $cwd = getcwd;
+$ENV{SHIPWRIGHT_SVK} ||= 'svk';
+$ENV{SHIPWRIGHT_SVN} ||= 'svn';
 Shipwright::Script->dispatch();
 chdir $cwd;

Modified: Shipwright/trunk/lib/Shipwright/Backend/SVK.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Backend/SVK.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Backend/SVK.pm	Fri Jan 16 05:07:06 2009
@@ -45,7 +45,7 @@
 sub _svnroot {
     my $self = shift;
     return $self->{svnroot} if $self->{svnroot};
-    my $depotmap = Shipwright::Util->run( [ svk => depotmap => '--list' ] );
+    my $depotmap = Shipwright::Util->run( [ $ENV{'SHIPWRIGHT_SVK'} => depotmap => '--list' ] );
     $depotmap =~ s{\A.*?^(?=/)}{}sm;
     while ($depotmap =~ /^(\S*)\s+(.*?)$/gm) {
         my ($depot, $svnroot) = ($1, $2);
@@ -72,11 +72,11 @@
 
     if ( $type eq 'checkout' ) {
         if ( $args{detach} ) {
-            @cmd = [ 'svk', 'checkout', '-d', $args{target} ];
+            @cmd = [ $ENV{'SHIPWRIGHT_SVK'}, 'checkout', '-d', $args{target} ];
         }
         else {
             @cmd = [
-                'svk',                           'checkout',
+                $ENV{'SHIPWRIGHT_SVK'},                           'checkout',
                 $self->repository . $args{path}, $args{target}
             ];
         }
@@ -95,14 +95,14 @@
     elsif ( $type eq 'import' ) {
         if ( $args{_initialize} ) {
             @cmd = [
-                'svk',         'import',
+                $ENV{'SHIPWRIGHT_SVK'},         'import',
                 $args{source}, $self->repository,
                 '-m',          $args{comment},
             ];
         }
         elsif ( $args{_extra_tests} ) {
             @cmd = [
-                'svk',         'import',
+                $ENV{'SHIPWRIGHT_SVK'},         'import',
                 $args{source}, $self->repository . '/t/extra',
                 '-m',          $args{comment},
             ];
@@ -126,20 +126,20 @@
                   tempdir( 'shipwright_backend_svk_XXXXXX', CLEANUP => 1, TMPDIR => 1 );
                 @cmd = (
                     [ 'rm', '-rf', "$tmp_dir" ],
-                    [ 'svk', 'checkout', $self->repository . $path, $tmp_dir ],
+                    [ $ENV{'SHIPWRIGHT_SVK'}, 'checkout', $self->repository . $path, $tmp_dir ],
                     [ 'rm',  '-rf',      "$tmp_dir" ],
                     [ 'cp', '-r', $source, "$tmp_dir" ],
                     [
-                        'svk',      'commit',
+                        $ENV{'SHIPWRIGHT_SVK'},      'commit',
                         '--import', $tmp_dir,
                         '-m',       $args{comment}
                     ],
-                    [ 'svk', 'checkout', '-d', $tmp_dir ],
+                    [ $ENV{'SHIPWRIGHT_SVK'}, 'checkout', '-d', $tmp_dir ],
                 );
             }
             else {
                 @cmd = [
-                    'svk',   'import',
+                    $ENV{'SHIPWRIGHT_SVK'},   'import',
                     $source, $self->repository . $path,
                     '-m',    $args{comment},
                 ];
@@ -148,18 +148,18 @@
     }
     elsif ( $type eq 'commit' ) {
         @cmd =
-          [ 'svk', 'commit', '-m', $args{comment}, $args{path} ];
+          [ $ENV{'SHIPWRIGHT_SVK'}, 'commit', '-m', $args{comment}, $args{path} ];
     }
     elsif ( $type eq 'delete' ) {
         @cmd = [
-            'svk', 'delete', '-m',
+            $ENV{'SHIPWRIGHT_SVK'}, 'delete', '-m',
             'delete repository',
             $self->repository . $args{path},
         ];
     }
     elsif ( $type eq 'move' ) {
         @cmd = [
-            'svk',
+            $ENV{'SHIPWRIGHT_SVK'},
             'move',
             '-m',
             "move $args{path} to $args{new_path}",
@@ -168,7 +168,7 @@
         ];
     }
     elsif ( $type eq 'info' ) {
-        @cmd = [ 'svk', 'info', $self->repository . $args{path} ];
+        @cmd = [ $ENV{'SHIPWRIGHT_SVK'}, 'info', $self->repository . $args{path} ];
     }
     elsif ( $type eq 'cat' ) {
         @cmd = [ 'svn', 'cat', $self->_svnroot . $args{path} ];
@@ -202,7 +202,7 @@
     }
     else {
         my ($out) =
-          Shipwright::Util->run( [ 'svk', 'cat', $self->repository . $path ] );
+          Shipwright::Util->run( [ $ENV{'SHIPWRIGHT_SVK'}, 'cat', $self->repository . $path ] );
         return Shipwright::Util::Load($out);
     }
 }

Modified: Shipwright/trunk/lib/Shipwright/Backend/SVN.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Backend/SVN.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Backend/SVN.pm	Fri Jan 16 05:07:06 2009
@@ -69,23 +69,23 @@
 
     if ( $type eq 'checkout' ) {
         @cmd =
-          [ 'svn', 'checkout', $self->repository . $args{path}, $args{target} ];
+          [ $ENV{'SHIPWRIGHT_SVN'}, 'checkout', $self->repository . $args{path}, $args{target} ];
     }
     elsif ( $type eq 'export' ) {
         @cmd =
-          [ 'svn', 'export', $self->repository . $args{path}, $args{target} ];
+          [ $ENV{'SHIPWRIGHT_SVN'}, 'export', $self->repository . $args{path}, $args{target} ];
     }
     elsif ( $type eq 'import' ) {
         if ( $args{_initialize} ) {
             @cmd = [
-                'svn',         'import',
+                $ENV{'SHIPWRIGHT_SVN'},         'import',
                 $args{source}, $self->repository,
                 '-m',          $args{comment},
             ];
         }
         elsif ( $args{_extra_tests} ) {
             @cmd = [
-                'svn',         'import',
+                $ENV{'SHIPWRIGHT_SVN'},         'import',
                 $args{source}, $self->repository . '/t/extra',
                 '-m',          $args{comment},
             ];
@@ -93,7 +93,7 @@
         else {
             if ( my $script_dir = $args{build_script} ) {
                 @cmd = [
-                    'svn',       'import',
+                    $ENV{'SHIPWRIGHT_SVN'},       'import',
                     $script_dir, $self->repository . "/scripts/$args{name}/",
                     '-m',        $args{comment},
                 ];
@@ -101,7 +101,7 @@
             else {
                 if ( $self->has_branch_support ) {
                     @cmd = [
-                        'svn',
+                        $ENV{'SHIPWRIGHT_SVN'},
                         'import',
                         $args{source},
                         $self->repository . "/sources/$args{name}/$args{as}",
@@ -111,7 +111,7 @@
                 }
                 else {
                     @cmd = [
-                        'svn',
+                        $ENV{'SHIPWRIGHT_SVN'},
                         'import',
                         $args{source},
                         $self->repository . "/dists/$args{name}",
@@ -124,22 +124,22 @@
         }
     }
     elsif ( $type eq 'list' ) {
-        @cmd = [ 'svn', 'list', $self->repository . $args{path} ];
+        @cmd = [ $ENV{'SHIPWRIGHT_SVN'}, 'list', $self->repository . $args{path} ];
     }
     elsif ( $type eq 'commit' ) {
         @cmd =
-          [ 'svn', 'commit', '-m', $args{comment}, $args{path} ];
+          [ $ENV{'SHIPWRIGHT_SVN'}, 'commit', '-m', $args{comment}, $args{path} ];
     }
     elsif ( $type eq 'delete' ) {
         @cmd = [
-            'svn', 'delete', '-m',
+            $ENV{'SHIPWRIGHT_SVN'}, 'delete', '-m',
             'delete ' . $args{path},
             $self->repository . $args{path},
         ];
     }
     elsif ( $type eq 'move' ) {
         @cmd = [
-            'svn',
+            $ENV{'SHIPWRIGHT_SVN'},
             'move',
             '-m',
             "move $args{path} to $args{new_path}",
@@ -148,10 +148,10 @@
         ];
     }
     elsif ( $type eq 'info' ) {
-        @cmd = [ 'svn', 'info', $self->repository . $args{path} ];
+        @cmd = [ $ENV{'SHIPWRIGHT_SVN'}, 'info', $self->repository . $args{path} ];
     }
     elsif ( $type eq 'cat' ) {
-        @cmd = [ 'svn', 'cat', $self->repository . $args{path} ];
+        @cmd = [ $ENV{'SHIPWRIGHT_SVN'}, 'cat', $self->repository . $args{path} ];
     }
     else {
         croak "invalid command: $type";
@@ -188,7 +188,7 @@
     }
     else {
         my ($out) =
-          Shipwright::Util->run( [ 'svn', 'cat', $self->repository . $path ] );
+          Shipwright::Util->run( [ $ENV{'SHIPWRIGHT_SVN'}, 'cat', $self->repository . $path ] );
         return Shipwright::Util::Load($out);
     }
 }

Modified: Shipwright/trunk/lib/Shipwright/Script/List.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Script/List.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Script/List.pm	Fri Jan 16 05:07:06 2009
@@ -128,11 +128,11 @@
         # has url, meaning svn or svk
         if ( $args{url} =~ /^svn[:+]/ ) {
             $args{url} =~ s{^svn:(?!//)}{};
-            $cmd = [ 'svn', 'info', $args{url} ];
+            $cmd = [ $ENV{'SHIPWRIGHT_SVN'}, 'info', $args{url} ];
         }
         elsif ( $args{url} =~ m{^(svk:|//)} ) {
             $args{url} =~ s/^svk://;
-            $cmd = [ 'svk', 'info', $args{url} ];
+            $cmd = [ $ENV{'SHIPWRIGHT_SVK'}, 'info', $args{url} ];
         }
 
         ($out) = Shipwright::Util->run( $cmd, 1 );    # ignore failure

Modified: Shipwright/trunk/lib/Shipwright/Source/SVK.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Source/SVK.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Source/SVK.pm	Fri Jan 16 05:07:06 2009
@@ -53,15 +53,21 @@
     my @cmds;
     push @cmds,
       [
-        'svk', 'co', $self->source,
+        $ENV{'SHIPWRIGHT_SVK'},
+        'co',
+        $self->source,
         catdir( $self->download_directory, $self->name ),
         $self->version ? ( '-r', $self->version ) : ()
       ];
     push @cmds,
-      [ 'svk', 'co', '-d', catdir( $self->download_directory, $self->name ), ];
+      [
+        $ENV{'SHIPWRIGHT_SVK'}, 'co', '-d',
+        catdir( $self->download_directory, $self->name ),
+      ];
 
     unless ( $self->version ) {
-        my ($out) = Shipwright::Util->run( [ 'svk', 'info', $self->source, ] );
+        my ($out) = Shipwright::Util->run(
+            [ $ENV{'SHIPWRIGHT_SVK'}, 'info', $self->source, ] );
 
         if ( $out =~ /^Revision: (\d+)/m ) {
             $self->version($1);

Modified: Shipwright/trunk/lib/Shipwright/Source/SVN.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Source/SVN.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Source/SVN.pm	Fri Jan 16 05:07:06 2009
@@ -50,13 +50,16 @@
     my $source = $self->source;
 
     my $cmd = [
-        'svn', 'export', $self->source,
+        $ENV{'SHIPWRIGHT_SVN'},
+        'export',
+        $self->source,
         catdir( $self->download_directory, $self->name ),
         $self->version ? ( '-r', $self->version ) : (),
     ];
 
     unless ( $self->version ) {
-        my ($out) = Shipwright::Util->run( [ 'svn', 'info', $source, ] );
+        my ($out) =
+          Shipwright::Util->run( [ $ENV{'SHIPWRIGHT_SVN'}, 'info', $source, ] );
 
         if ( $out =~ /^Revision: (\d+)/m ) {
             $self->version($1);

Modified: Shipwright/trunk/lib/Shipwright/Test.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Test.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Test.pm	Fri Jan 16 05:07:06 2009
@@ -29,8 +29,11 @@
 =cut
 
 sub has_svk {
-    if ( can_run('svk') && can_run('svnadmin') ) {
-        my $out = Shipwright::Util->run( [ 'svk', '--version' ], 1 );
+    if (   can_run( $ENV{'SHIPWRIGHT_SVK'} )
+        && can_run( $ENV{'SHIPWRIGHT_SVN'} . 'admin' ) )
+    {
+        my $out =
+          Shipwright::Util->run( [ $ENV{'SHIPWRIGHT_SVK'}, '--version' ], 1 );
         if ( $out && $out =~ /version v(\d)\./i ) {
             return 1 if $1 >= 2;
         }
@@ -46,8 +49,11 @@
 =cut
 
 sub has_svn {
-    if ( can_run('svn') && can_run('svnadmin') ) {
-        my $out = Shipwright::Util->run( [ 'svn', '--version' ], 1 );
+    if (   can_run( $ENV{'SHIPWRIGHT_SVN'} )
+        && can_run( $ENV{'SHIPWRIGHT_SVN'} . 'admin' ) )
+    {
+        my $out =
+          Shipwright::Util->run( [ $ENV{'SHIPWRIGHT_SVN'}, '--version' ], 1 );
         if ( $out && $out =~ /version 1\.(\d)/i ) {
             return 1 if $1 >= 4;
         }
@@ -102,8 +108,8 @@
     $ENV{SVKROOT} =
       tempdir( 'shipwright_test_svk_XXXXXX', CLEANUP => 1, TMPDIR => 1 );
     my $svk_root_local = catdir( $ENV{SVKROOT}, 'local' );
-    system("svnadmin create $svk_root_local");
-    system("svk depotmap -i");
+    system("$ENV{SHIPWRIGHT_SVN}admin create $svk_root_local");
+    system("$ENV{SHIPWRIGHT_SVK} depotmap -i");
     return $ENV{SVKROOT};
 }
 
@@ -117,7 +123,8 @@
 sub create_svn_repo {
     my $repo =
       tempdir( 'shipwright_test_svn_XXXXXX', CLEANUP => 1, TMPDIR => 1 );
-    system("svnadmin create $repo") && confess "create repo failed: $!";
+    system("$ENV{SHIPWRIGHT_SVN}admin create $repo")
+      && confess "create repo failed: $!";
     return "file://$repo";
 }
 
@@ -130,6 +137,8 @@
 sub init {
     require Shipwright::Logger;
     Shipwright::Logger->new( log_level => 'FATAL' );
+    $ENV{'SHIPWRIGHT_SVK'} ||= 'svk';
+    $ENV{'SHIPWRIGHT_SVN'} ||= 'svn';
 }
 
 =head2 shipwright_bin

Modified: Shipwright/trunk/t/01.repo_check.t
==============================================================================
--- Shipwright/trunk/t/01.repo_check.t	(original)
+++ Shipwright/trunk/t/01.repo_check.t	Fri Jan 16 05:07:06 2009
@@ -25,7 +25,7 @@
             $repo => 1,
 
           # yeah, fs can create anywhere, but this may fail if permission denied
-            'fs:/noexists/blalba' => 1,
+            'fs:/noexists/bla' => 1,
         },
         list => {
             'fs:/noexists/bla' => undef,

Modified: Shipwright/trunk/t/71.script_cmds.t
==============================================================================
--- Shipwright/trunk/t/71.script_cmds.t	(original)
+++ Shipwright/trunk/t/71.script_cmds.t	Fri Jan 16 05:07:06 2009
@@ -15,36 +15,50 @@
 my $build_base   = catdir( tmpdir(), 'shipwright_build_71_scripts_cmds' );
 
 {
+
     # fs backend
-    start_test('fs:' . create_fs_repo() );
+    start_test( 'fs:' . create_fs_repo() );
 }
 
-
 SKIP: {
-    skip "svn: no svn found or env SHIPWRIGHT_TEST_BACKEND_SVN not set", 36 if skip_svn();
+    skip "svn: no svn found or env SHIPWRIGHT_TEST_BACKEND_SVN not set", 36
+      if skip_svn();
 
     my $repo = 'svn:' . create_svn_repo() . '/hello';
 
     my $source = create_svn_repo() . '/foo';    # svn source we'll import
 
     Shipwright::Util->run(
-        [ 'svn', 'import', '-m', q{''}, 't/dists/version1', $source ] );
+        [
+            $ENV{'SHIPWRIGHT_SVN'}, 'import',
+            '-m',                   q{''},
+            't/dists/version1',     $source
+        ]
+    );
 
     my $update_cmd = [
-        'svn', 'import', '-m', q{''}, 't/dists/version2', $source . '/version2'
+        $ENV{'SHIPWRIGHT_SVN'}, 'import',
+        '-m',                   q{''},
+        't/dists/version2',     $source . '/version2'
     ];
     start_test( $repo, "svn:$source", $update_cmd );
 }
 
 SKIP: {
-    skip "svk: no svk found or env SHIPWRIGHT_TEST_BACKEND_SVK not set", 36 if skip_svk();
+    skip "svk: no svk found or env SHIPWRIGHT_TEST_BACKEND_SVK not set", 36
+      if skip_svk();
 
     create_svk_repo();
 
     my $repo   = 'svk://__shipwright/hello';
     my $source = '//foo';
     Shipwright::Util->run(
-        [ 'svk', 'import', '-m', q{''}, 't/dists/version1', $source ] );
+        [
+            $ENV{'SHIPWRIGHT_SVK'}, 'import',
+            '-m',                   q{''},
+            't/dists/version1',     $source
+        ]
+    );
 
     start_test( $repo, "svk:$source" );
 
@@ -283,6 +297,7 @@
 
         $source
         ? (
+
             # import an svn or svk dist named foo
             [
                 [ 'import', $source ],
@@ -290,7 +305,7 @@
                 "imported $source",
             ],
             $update_cmd,    # if the source dist is svk, $update_cmd is undef
-            # update cmd
+                            # update cmd
             [ [ 'update', 'foo' ], qr/updated with success/, "updated foo", ],
           )
         : (),
@@ -307,8 +322,8 @@
                 @$item[ 1 .. $#$item ],
             );
             if ( $cmd eq 'build' ) {
-                rmtree( $install_base );
-                rmtree( $build_base );
+                rmtree($install_base);
+                rmtree($build_base);
             }
         }
         else {



More information about the Bps-public-commit mailing list