[Bps-public-commit] r18510 - in Shipwright/trunk: lib/Shipwright/Backend

sunnavy at bestpractical.com sunnavy at bestpractical.com
Sat Feb 21 06:42:16 EST 2009


Author: sunnavy
Date: Sat Feb 21 06:42:12 2009
New Revision: 18510

Modified:
   Shipwright/trunk/   (props changed)
   Shipwright/trunk/lib/Shipwright/Backend/Base.pm
   Shipwright/trunk/lib/Shipwright/Backend/FS.pm
   Shipwright/trunk/lib/Shipwright/Backend/SVK.pm
   Shipwright/trunk/lib/Shipwright/Backend/SVN.pm

Log:
 r20025 at sunnavys-mb:  sunnavy | 2009-02-21 19:37:56 +0800
 make update to handle dir


Modified: Shipwright/trunk/lib/Shipwright/Backend/Base.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Backend/Base.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Backend/Base.pm	Sat Feb 21 06:42:12 2009
@@ -692,11 +692,31 @@
 
     croak "need path option" unless $args{path};
 
-    croak "$args{path} seems not shipwright's own file"
-      unless -e catfile( Shipwright::Util->share_root, $args{path} );
+    if ( $args{path} =~ m{/$} ) {
+        # it's a directory
+        if ( $args{path} eq '/inc/' && ! $args{source} ) {
+            my $dir = tempdir(
+                'shipwright_backend_base_XXXXXX',
+                CLEANUP => 1,
+                TMPDIR  => 1,
+            );
+            $self->_install_yaml_tiny($dir);
+            $self->_install_clean_inc($dir);
+            $self->_install_module_build($dir);
+            $self->_update_dir( '/inc/', catdir($dir, 'inc') );
+        }
+        elsif ( $args{source} ) {
+            $self->_update_dir( $args{path}, $args{source} );
+        }
+    }
+    else {
+
+        croak "$args{path} seems not shipwright's own file"
+          unless -e catfile( Shipwright::Util->share_root, $args{path} );
 
-    return $self->_update_file( $args{path},
-        catfile( Shipwright::Util->share_root, $args{path} ) );
+        return $self->_update_file( $args{path},
+            catfile( Shipwright::Util->share_root, $args{path} ) );
+    }
 }
 
 =item test_script

Modified: Shipwright/trunk/lib/Shipwright/Backend/FS.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Backend/FS.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Backend/FS.pm	Sat Feb 21 06:42:12 2009
@@ -192,6 +192,15 @@
     copy( $latest, $file );
 }
 
+sub _update_dir {
+    my $self   = shift;
+    my $path   = shift;
+    my $latest = shift;
+
+    my $dir = catfile( $self->repository, $path );
+    dircopy( $latest, $dir );
+}
+
 =item import
 
 =cut

Modified: Shipwright/trunk/lib/Shipwright/Backend/SVK.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Backend/SVK.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Backend/SVK.pm	Sat Feb 21 06:42:12 2009
@@ -7,6 +7,7 @@
 use Shipwright::Util;
 use File::Temp qw/tempdir/;
 use File::Copy qw/copy/;
+use File::Copy::Recursive qw/dircopy/;
 
 our %REQUIRE_OPTIONS = ( import => [qw/source/] );
 
@@ -95,9 +96,9 @@
     elsif ( $type eq 'import' ) {
         if ( $args{_initialize} ) {
             @cmd = [
-                $ENV{'SHIPWRIGHT_SVK'},         'import',
-                $args{source}, $self->repository,
-                '-m',          $args{comment},
+                $ENV{'SHIPWRIGHT_SVK'}, 'import', $args{source},
+                $self->repository . ( $args{path} || '' ),
+                '-m', $args{comment},
             ];
         }
         elsif ( $args{_extra_tests} ) {
@@ -147,8 +148,18 @@
         }
     }
     elsif ( $type eq 'commit' ) {
-        @cmd =
-          [ $ENV{'SHIPWRIGHT_SVK'}, 'commit', '-m', $args{comment}, $args{path} ];
+        @cmd = [
+            $ENV{'SHIPWRIGHT_SVK'},
+            'commit',
+            (
+                $args{import}
+                ? '--import'
+                : ()
+            ),
+            '-m',
+            $args{comment},
+            $args{path}
+        ];
     }
     elsif ( $type eq 'delete' ) {
         @cmd = [
@@ -282,6 +293,29 @@
     $self->checkout( detach => 1, target => $file );
 }
 
+sub _update_dir {
+    my $self   = shift;
+    my $path   = shift;
+    my $latest = shift;
+
+    my $dir =
+      tempdir( 'shipwright_backend_svk_XXXXXX', CLEANUP => 1, TMPDIR => 1 );
+    rmdir $dir;
+
+    $self->checkout(
+        path   => $path,
+        target => $dir,
+    );
+
+    dircopy( $latest, $dir );
+    $self->commit(
+        path    => $dir,
+        comment => "updated $path",
+        import  => 1,
+    );
+    $self->checkout( detach => 1, target => $dir );
+}
+
 =back
 
 =cut

Modified: Shipwright/trunk/lib/Shipwright/Backend/SVN.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Backend/SVN.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Backend/SVN.pm	Sat Feb 21 06:42:12 2009
@@ -7,6 +7,7 @@
 use Shipwright::Util;
 use File::Temp qw/tempdir/;
 use File::Copy qw/copy/;
+use File::Copy::Recursive qw/dircopy/;
 
 our %REQUIRE_OPTIONS = ( import => [qw/source/] );
 
@@ -78,9 +79,9 @@
     elsif ( $type eq 'import' ) {
         if ( $args{_initialize} ) {
             @cmd = [
-                $ENV{'SHIPWRIGHT_SVN'},         'import',
-                $args{source}, $self->repository,
-                '-m',          $args{comment},
+                $ENV{'SHIPWRIGHT_SVN'}, 'import', $args{source},
+                $self->repository . ( $args{path} || '' ),
+                '-m', $args{comment},
             ];
         }
         elsif ( $args{_extra_tests} ) {
@@ -267,6 +268,16 @@
     }
 }
 
+sub _update_dir {
+    my $self   = shift;
+    my $path   = shift;
+    my $latest = shift;
+
+    $self->delete( path => $path );
+    $self->import( path => $path, source => $latest, _initialize => 1 );
+}
+
+
 =back
 
 =cut



More information about the Bps-public-commit mailing list