[Bps-public-commit] r12258 - Shipwright/trunk/lib/Shipwright/Script

sunnavy at bestpractical.com sunnavy at bestpractical.com
Mon May 12 12:05:58 EDT 2008


Author: sunnavy
Date: Mon May 12 12:05:58 2008
New Revision: 12258

Modified:
   /   (props changed)
   Shipwright/trunk/lib/Shipwright/Backend/SVK.pm
   Shipwright/trunk/lib/Shipwright/Backend/SVN.pm
   Shipwright/trunk/lib/Shipwright/Script/Update.pm

Log:
 r12273 at sunnavys-mb:  sunnavy | 2008-05-12 22:42:14 +0800
 refactor: rename dist arg to name; delete accept path => $path only, same as info


Modified: Shipwright/trunk/lib/Shipwright/Backend/SVK.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Backend/SVK.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Backend/SVK.pm	Mon May 12 12:05:58 2008
@@ -77,7 +77,7 @@
                 );
             }
             else {
-                $self->delete("scripts/$name");
+                $self->delete( path => "scripts/$name");
                 $self->log->info(
                     "import $args{source}'s scripts to " . $self->repository );
                 Shipwright::Util->run(
@@ -91,12 +91,12 @@
                 );
             }
             else {
-                $self->delete("dists/$name");
+                $self->delete( path => "dists/$name");
                 $self->log->info(
                     "import $args{source} to " . $self->repository );
                 $self->_add_to_order($name);
                 $self->version(
-                    dist    => $name,
+                    name    => $name,
                     version => $args{version},
                 );
 
@@ -285,7 +285,7 @@
     my $require = {};
 
     for (@dists) {
-        $self->_fill_deps( %args, require => $require, dist => $_ );
+        $self->_fill_deps( %args, require => $require, name => $_ );
     }
 
     require Algorithm::Dependency::Ordered;
@@ -304,27 +304,27 @@
     my $self    = shift;
     my %args    = @_;
     my $require = $args{require};
-    my $dist    = $args{dist};
+    my $name    = $args{name};
 
     my ($string) = Shipwright::Util->run(
-        [ 'svk', 'cat', $self->repository . "/scripts/$dist/require.yml" ], 1 );
+        [ 'svk', 'cat', $self->repository . "/scripts/$name/require.yml" ], 1 );
     my $req = Shipwright::Util::Load($string) || {};
 
     if ( $req->{requires} ) {
         for (qw/requires recommends build_requires/) {
-            push @{ $require->{$dist} }, keys %{ $req->{$_} }
+            push @{ $require->{$name} }, keys %{ $req->{$_} }
               if $args{"keep_$_"};
         }
     }
     else {
 
         #for back compatbility
-        push @{ $require->{$dist} }, keys %$req;
+        push @{ $require->{$name} }, keys %$req;
     }
 
-    for my $dep ( @{ $require->{$dist} } ) {
+    for my $dep ( @{ $require->{$name} } ) {
         next if $require->{$dep};
-        $self->_fill_deps( %args, dist => $dep );
+        $self->_fill_deps( %args, name => $dep );
     }
 }
 
@@ -423,7 +423,8 @@
 
 sub delete {
     my $self = shift;
-    my $path = shift || '';
+    my %args = @_;
+    my $path = $args{path} || '';
     if ( $self->info( path => $path) ) {
         $self->log->info( "delete " . $self->repository . "/$path" );
         Shipwright::Util->run( $self->_cmd( delete => path => $path ), 1 );
@@ -439,7 +440,7 @@
 sub info {
     my $self = shift;
     my %args = @_;
-    my $path = $args{path};
+    my $path = $args{path} || '';
 
     my ( $info, $err ) =
       Shipwright::Util->run( $self->_cmd( info => path => $path ), 1 );
@@ -499,7 +500,8 @@
 
 sub requires {
     my $self = shift;
-    my $name = shift;
+    my %args = @_;
+    my $name = $args{$name};
 
     my ($string) = Shipwright::Util->run(
         [ 'svk', 'cat', $self->repository . "/scripts/$name/require.yml" ], 1 );
@@ -516,7 +518,7 @@
     my $self = shift;
     my %args = @_;
 
-    croak "need dist arg" unless $args{dist};
+    croak "need name arg" unless $args{name};
 
     if ( $args{flags} ) {
         my $dir = tempdir( CLEANUP => 1 );
@@ -528,17 +530,17 @@
         );
 
         my $flags = Shipwright::Util::LoadFile($file);
-        $flags->{ $args{dist} } = $args{flags};
+        $flags->{ $args{name} } = $args{flags};
 
         Shipwright::Util::DumpFile( $file, $flags );
-        $self->commit( path => $file, comment => "set flags for $args{dist}" );
+        $self->commit( path => $file, comment => "set flags for $args{name}" );
         $self->checkout( detach => 1, target => $file );
     }
     else {
         my ($out) = Shipwright::Util->run(
             [ 'svk', 'cat', $self->repository . '/shipwright/flags.yml' ] );
         $out = Shipwright::Util::Load($out) || {};
-        return $out->{ $args{dist} } || [];
+        return $out->{ $args{name} } || [];
     }
 }
 
@@ -552,7 +554,7 @@
     my $self = shift;
     my %args = @_;
 
-    croak "need dist arg" unless $args{dist};
+    croak "need name arg" unless $args{name};
 
     if ( exists $args{version} ) {
         my $dir = tempdir( CLEANUP => 1 );
@@ -564,12 +566,12 @@
         );
 
         my $version = Shipwright::Util::LoadFile($file);
-        $version->{ $args{dist} } = $args{version};
+        $version->{ $args{name} } = $args{version};
 
         Shipwright::Util::DumpFile( $file, $version );
         $self->commit(
             path    => $file,
-            comment => "set version for $args{dist}"
+            comment => "set version for $args{name}"
         );
         $self->checkout( detach => 1, target => $file );
     }
@@ -577,7 +579,7 @@
         my ($out) = Shipwright::Util->run(
             [ 'svk', 'cat', $self->repository . '/shipwright/version.yml' ] );
         $out = Shipwright::Util::Load($out) || {};
-        return $out->{ $args{dist} };
+        return $out->{ $args{name} };
     }
 }
 

Modified: Shipwright/trunk/lib/Shipwright/Backend/SVN.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Backend/SVN.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Backend/SVN.pm	Mon May 12 12:05:58 2008
@@ -71,7 +71,7 @@
 
     unless ( $args{_initialize} ) {
         if ( $args{_extra_tests} ) {
-            $self->delete("t/extra");
+            $self->delete( path => "t/extra");
             $self->log->info( "import extra tests to " . $self->repository );
             Shipwright::Util->run(
                 $self->_cmd( import => %args, name => $name ) );
@@ -85,7 +85,7 @@
                 );
             }
             else {
-                $self->delete("scripts/$name");
+                $self->delete( path => "scripts/$name");
                 $self->log->info(
                     "import $args{source}'s scripts to " . $self->repository );
                 Shipwright::Util->run(
@@ -100,12 +100,12 @@
                 );
             }
             else {
-                $self->delete("dists/$name");
+                $self->delete( path => "dists/$name");
                 $self->log->info(
                     "import $args{source} to " . $self->repository );
                 $self->_add_to_order($name);
                 $self->version(
-                    dist    => $name,
+                    name    => $name,
                     version => $args{version},
                 );
 
@@ -284,7 +284,7 @@
     my $require = {};
 
     for (@dists) {
-        $self->_fill_deps( %args, require => $require, dist => $_ );
+        $self->_fill_deps( %args, require => $require, name => $_ );
     }
 
     require Algorithm::Dependency::Ordered;
@@ -302,7 +302,7 @@
     my $self    = shift;
     my %args    = @_;
     my $require = $args{require};
-    my $dist    = $args{dist};
+    my $name    = $args{name};
 
     my ($string) = Shipwright::Util->run(
         [ 'svn', 'cat', $self->repository . "/scripts/$_/require.yml" ], 1 );
@@ -311,19 +311,19 @@
 
     if ( $req->{requires} ) {
         for (qw/requires recommends build_requires/) {
-            push @{ $require->{$dist} }, keys %{ $req->{$_} }
+            push @{ $require->{$name} }, keys %{ $req->{$_} }
               if $args{"keep_$_"};
         }
     }
     else {
 
         #for back compatbility
-        push @{ $require->{$dist} }, keys %$req;
+        push @{ $require->{$name} }, keys %$req;
     }
 
-    for my $dep ( @{ $require->{$dist} } ) {
+    for my $dep ( @{ $require->{$name} } ) {
         next if $require->{$dep};
-        $self->_fill_deps( %args, dist => $dep );
+        $self->_fill_deps( %args, name => $dep );
     }
 }
 
@@ -422,7 +422,9 @@
 
 sub delete {
     my $self = shift;
-    my $path = shift || '';
+    my %args = @_;
+
+    my $path = $args{path} || '';
     if ( $self->info( path => $path ) ) {
         $self->log->info( "delete " . $self->repository . "/$path" );
         Shipwright::Util->run( $self->_cmd( delete => path => $path ), 1 );
@@ -438,7 +440,7 @@
 sub info {
     my $self = shift;
     my %args = @_;
-    my $path = $args{path};
+    my $path = $args{path} || '';
 
     my ( $info, $err ) =
       Shipwright::Util->run( $self->_cmd( info => path => $path ), 1 );
@@ -529,7 +531,7 @@
     my $self = shift;
     my %args = @_;
 
-    croak "need dist arg" unless $args{dist};
+    croak "need name arg" unless $args{name};
 
     if ( $args{flags} ) {
         my $dir = tempdir( CLEANUP => 1 );
@@ -541,16 +543,16 @@
         );
 
         my $flags = Shipwright::Util::LoadFile($file);
-        $flags->{ $args{dist} } = $args{flags};
+        $flags->{ $args{name} } = $args{flags};
 
         Shipwright::Util::DumpFile( $file, $flags );
-        $self->commit( path => $file, comment => "set flags for $args{dist}" );
+        $self->commit( path => $file, comment => "set flags for $args{name}" );
     }
     else {
         my ($out) = Shipwright::Util->run(
             [ 'svn', 'cat', $self->repository . '/shipwright/flags.yml' ] );
         $out = Shipwright::Util::Load($out) || {};
-        return $out->{ $args{dist} } || [];
+        return $out->{ $args{name} } || [];
     }
 }
 
@@ -564,7 +566,7 @@
     my $self = shift;
     my %args = @_;
 
-    croak "need dist arg" unless $args{dist};
+    croak "need name arg" unless $args{name};
 
     if ( exists $args{version} ) {
         my $dir = tempdir( CLEANUP => 1 );
@@ -576,12 +578,12 @@
         );
 
         my $version = Shipwright::Util::LoadFile($file);
-        $version->{ $args{dist} } = $args{version};
+        $version->{ $args{name} } = $args{version};
 
         Shipwright::Util::DumpFile( $file, $version );
         $self->commit(
             path    => $file,
-            comment => "set version for $args{dist}"
+            comment => "set version for $args{name}"
         );
     }
     else {

Modified: Shipwright/trunk/lib/Shipwright/Script/Update.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Script/Update.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Script/Update.pm	Mon May 12 12:05:58 2008
@@ -73,7 +73,7 @@
 
                 return if $checked{$name}++; # we've checked this $name
 
-                my ($require) = $shipwright->backend->requires($name);
+                my ($require) = $shipwright->backend->requires( name => $name );
                 for my $type (qw/requires build_requires recommends/) {
                     for ( keys %{ $require->{$type} } ) {
                         $find_deps->( $_ );



More information about the Bps-public-commit mailing list