[Bps-public-commit] r12243 -

sunnavy at bestpractical.com sunnavy at bestpractical.com
Mon May 12 06:44:24 EDT 2008


Author: sunnavy
Date: Mon May 12 06:44:21 2008
New Revision: 12243

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

Log:
 r12248 at sunnavys-mb:  sunnavy | 2008-05-12 16:25:33 +0800
 info returns differ given wantarray or not


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 06:44:21 2008
@@ -444,8 +444,14 @@
     my ( $info, $err ) =
       Shipwright::Util->run( $self->_cmd( info => path => $path ), 1 );
     $self->log->warn($err) if $err;
-    return if $info =~ /not exist|not a checkout path/;
-    return $info;
+
+    if ( wantarray ) {
+        return $info, $err;
+    }
+    else {
+        return if $info =~ /not exist|not a checkout path/;
+        return $info;
+    }
 }
 
 =head2 propset

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 06:44:21 2008
@@ -77,7 +77,9 @@
                 $self->_cmd( import => %args, name => $name ) );
         }
         elsif ( $args{build_script} ) {
-            if ( $self->info( path => "scripts/$name") && not $args{overwrite} ) {
+            if ( $self->info( path => "scripts/$name" )
+                && not $args{overwrite} )
+            {
                 $self->log->warn(
 "path scripts/$name alreay exists, need to set overwrite arg to overwrite"
                 );
@@ -91,7 +93,8 @@
             }
         }
         else {
-            if ( $self->info( path => "dists/$name") && not $args{overwrite} ) {
+            if ( $self->info( path => "dists/$name" ) && not $args{overwrite} )
+            {
                 $self->log->warn(
 "path dists/$name alreay exists, need to set overwrite arg to overwrite"
                 );
@@ -100,7 +103,7 @@
                 $self->delete("dists/$name");
                 $self->log->info(
                     "import $args{source} to " . $self->repository );
-                $self->_add_to_order( $name );
+                $self->_add_to_order($name);
                 $self->version(
                     dist    => $name,
                     version => $args{version},
@@ -420,7 +423,7 @@
 sub delete {
     my $self = shift;
     my $path = shift || '';
-    if ( $self->info( path => $path) ) {
+    if ( $self->info( path => $path ) ) {
         $self->log->info( "delete " . $self->repository . "/$path" );
         Shipwright::Util->run( $self->_cmd( delete => path => $path ), 1 );
     }
@@ -439,12 +442,18 @@
 
     my ( $info, $err ) =
       Shipwright::Util->run( $self->_cmd( info => path => $path ), 1 );
-    if ($err) {
-        $err =~ s/\s+$//;
-        $self->log->warn($err);
-        return;
+
+    if (wantarray) {
+        return $info, $err;
+    }
+    else {
+        if ($err) {
+            $err =~ s/\s+$//;
+            $self->log->warn($err);
+            return;
+        }
+        return $info;
     }
-    return $info;
 }
 
 =head2 propset
@@ -517,12 +526,12 @@
 =cut
 
 sub flags {
-    my $self   = shift;
+    my $self = shift;
     my %args = @_;
 
     croak "need dist arg" unless $args{dist};
 
-    if ($args{flags}) {
+    if ( $args{flags} ) {
         my $dir = tempdir( CLEANUP => 1 );
         my $file = File::Spec->catfile( $dir, 'flags.yml' );
 
@@ -531,8 +540,8 @@
             target => $dir,
         );
 
-        my $flags = Shipwright::Util::LoadFile( $file );
-        $flags->{$args{dist}} = $args{flags};
+        my $flags = Shipwright::Util::LoadFile($file);
+        $flags->{ $args{dist} } = $args{flags};
 
         Shipwright::Util::DumpFile( $file, $flags );
         $self->commit( path => $file, comment => "set flags for $args{dist}" );
@@ -541,7 +550,7 @@
         my ($out) = Shipwright::Util->run(
             [ 'svn', 'cat', $self->repository . '/shipwright/flags.yml' ] );
         $out = Shipwright::Util::Load($out) || {};
-        return $out->{$args{dist}} || []; 
+        return $out->{ $args{dist} } || [];
     }
 }
 
@@ -552,7 +561,7 @@
 =cut
 
 sub version {
-    my $self   = shift;
+    my $self = shift;
     my %args = @_;
 
     croak "need dist arg" unless $args{dist};
@@ -566,17 +575,20 @@
             target => $dir,
         );
 
-        my $version = Shipwright::Util::LoadFile( $file );
-        $version->{$args{dist}} = $args{version};
+        my $version = Shipwright::Util::LoadFile($file);
+        $version->{ $args{dist} } = $args{version};
 
         Shipwright::Util::DumpFile( $file, $version );
-        $self->commit( path => $file, comment => "set version for $args{dist}" );
+        $self->commit(
+            path    => $file,
+            comment => "set version for $args{dist}"
+        );
     }
     else {
         my ($out) = Shipwright::Util->run(
             [ 'svn', 'cat', $self->repository . '/shipwright/version.yml' ] );
         $out = Shipwright::Util::Load($out) || {};
-        return $out->{$args{version}}; 
+        return $out->{ $args{version} };
     }
 }
 
@@ -605,9 +617,9 @@
 
     if ( $args{action} eq 'create' ) {
 
-            my $info = $self->info;
+        my ( $info, $err ) = $self->info;
 
-            return 1 if $info;
+        return 1 if $info || $err && $err =~ /Not a valid URL/;
 
     }
     else {



More information about the Bps-public-commit mailing list