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

sunnavy at bestpractical.com sunnavy at bestpractical.com
Mon Nov 10 04:24:36 EST 2008


Author: sunnavy
Date: Mon Nov 10 04:24:35 2008
New Revision: 16800

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

Log:
 r17638 at sunnavys-mb:  sunnavy | 2008-11-09 10:21:21 +0800
 changes to make 2.x compatible with 1.x


Modified: Shipwright/trunk/lib/Shipwright/Backend/Base.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Backend/Base.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Backend/Base.pm	Mon Nov 10 04:24:35 2008
@@ -92,11 +92,13 @@
     my $name = $args{source};
     $name =~ s{.*/}{};
 
-    if ( $args{branches} ) {
-        $args{as} = '';
-    }
-    else {
-        $args{as} ||= 'vendor';
+    if ( $self->has_branch_support ) {
+        if ( $args{branches} ) {
+            $args{as} = '';
+        }
+        else {
+            $args{as} ||= 'vendor';
+        }
     }
 
     unless ( $args{_initialize} || $args{_extra_tests} ) {
@@ -129,45 +131,71 @@
             }
         }
         else {
-            if ( $self->info( path => "/sources/$name/$args{as}" )
-                && not $args{overwrite} )
-            {
-                $self->log->warn(
+            if ( $self->has_branch_support ) {
+                if ( $self->info( path => "/sources/$name/$args{as}" )
+                    && not $args{overwrite} )
+                {
+                    $self->log->warn(
 "path sources/$name/$args{as} alreay exists, need to set overwrite arg to overwrite"
-                );
-            }
-            else {
-                $self->delete( path => "/sources/$name/$args{as}" )
-                  if $args{delete};
-                $self->log->info(
-                    "import $args{source} to " . $self->repository );
-                $self->_add_to_order($name);
-
-                my $version = $self->version;
-                $version->{$name} = $args{version};
-                $self->version($version);
+                    );
+                }
+                else {
+                    $self->delete( path => "/sources/$name/$args{as}" )
+                      if $args{delete};
+                    $self->log->info(
+                        "import $args{source} to " . $self->repository );
+                    $self->_add_to_order($name);
+
+                    my $version = $self->version;
+                    $version->{$name} = $args{version};
+                    $self->version($version);
 
-                my $branches = $self->branches;
-                if ( $args{branches} ) {
+                    my $branches = $self->branches;
+                    if ( $args{branches} ) {
 
                   # mostly this happens when import from another shipwright repo
-                    $branches->{$name} = $args{branches};
-                    $self->branches($branches);
+                        $branches->{$name} = $args{branches};
+                        $self->branches($branches);
+                    }
+                    elsif (
+                        !(
+                            $branches->{$name} && grep { $args{as} eq $_ }
+                            @{ $branches->{$name} }
+                        )
+                      )
+                    {
+                        $branches->{$name} =
+                          [ @{ $branches->{$name} || [] }, $args{as} ];
+                        $self->branches($branches);
+                    }
+
+                    for
+                      my $cmd ( $self->_cmd( import => %args, name => $name ) )
+                    {
+                        Shipwright::Util->run($cmd);
+                    }
                 }
-                elsif (
-                    !(
-                        $branches->{$name} && grep { $args{as} eq $_ }
-                        @{ $branches->{$name} }
-                    )
-                  )
+            }
+            else {
+                if ( $self->info( path => "/dists/$name" )
+                    && not $args{overwrite} )
                 {
-                    $branches->{$name} =
-                      [ @{ $branches->{$name} || [] }, $args{as} ];
-                    $self->branches($branches);
+                    $self->log->warn(
+"path dists/$name alreay exists, need to set overwrite arg to overwrite"
+                    );
                 }
+                else {
+                    $self->delete( path => "/dists/$name" ) if $args{delete};
+                    $self->log->info(
+                        "import $args{source} to " . $self->repository );
+                    $self->_add_to_order($name);
+
+                    my $version = $self->version;
+                    $version->{$name} = $args{version};
+                    $self->version($version);
 
-                for my $cmd ( $self->_cmd( import => %args, name => $name ) ) {
-                    Shipwright::Util->run($cmd);
+                    Shipwright::Util->run(
+                        $self->_cmd( import => %args, name => $name ) );
                 }
             }
         }
@@ -280,7 +308,7 @@
       or confess $@;
     my $order = $dep->schedule_all();
 
-    $order = $self->fiddle_order( $order );
+    $order = $self->fiddle_order($order);
 
     $self->order($order);
 }
@@ -301,18 +329,19 @@
 =cut
 
 sub fiddle_order {
-    my $self = shift;
+    my $self       = shift;
     my $orig_order = shift;
 
     my $order;
-    if ( $orig_order ) {
+    if ($orig_order) {
+
         # don't change the argument
-        $order = [ @$orig_order ];
+        $order = [@$orig_order];
     }
     else {
         $order = $self->order;
     }
-   
+
     for my $maker ( 'cpan-Module-Build', 'cpan-ExtUtils-MakeMaker' ) {
         if ( grep { $_ eq $maker } @$order ) {
             @$order = grep { $_ ne $maker } @$order;
@@ -322,7 +351,8 @@
 
             if ( $maker eq 'cpan-Module-Build' ) {
 
-                my @maker_recommends; 
+                my @maker_recommends;
+
                 # cpan-Regexp-Common is the dep of cpan-Pod-Readme
                 for my $r (
                     'cpan-Regexp-Common', 'cpan-Pod-Readme',
@@ -466,8 +496,13 @@
     my $self     = shift;
     my $branches = shift;
 
-    my $path = '/shipwright/branches.yml';
-    return $self->_yml( $path, $branches );
+    if ( $self->has_branch_support ) {
+        my $path = '/shipwright/branches.yml';
+        return $self->_yml( $path, $branches );
+    }
+
+    # no branches support in 1.x
+    return;
 }
 
 =item ktf
@@ -686,7 +721,12 @@
     my $flags   = $self->flags || {};
 
     for my $name (@names_to_trim) {
-        $self->delete( path => "/sources/$name" );
+        if ( $self->has_branch_support ) {
+            $self->delete( path => "/sources/$name" );
+        }
+        else {
+            $self->delete( path => "/sources/$name" );
+        }
         $self->delete( path => "/scripts/$name" );
 
         # clean order.yml



More information about the Bps-public-commit mailing list