[Bps-public-commit] Shipwright branch, master, updated. 31706a7f2a4c5fba18ef7a2f589359998d0d8d21

? sunnavy sunnavy at bestpractical.com
Thu Dec 9 07:47:15 EST 2010


The branch, master has been updated
       via  31706a7f2a4c5fba18ef7a2f589359998d0d8d21 (commit)
      from  9640160a54359acd27ce7aaf9957a671aa8acfc1 (commit)

Summary of changes:
 lib/Shipwright/Script/Import.pm |    5 +++++
 lib/Shipwright/Source/Base.pm   |   33 ++++++++++++++++++++++-----------
 2 files changed, 27 insertions(+), 11 deletions(-)

- Log -----------------------------------------------------------------
commit 31706a7f2a4c5fba18ef7a2f589359998d0d8d21
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Dec 9 20:46:56 2010 +0800

    it's not accurate to use map.yml to test if a module is imported or not, use order.yml instead

diff --git a/lib/Shipwright/Script/Import.pm b/lib/Shipwright/Script/Import.pm
index ec58642..6da10f8 100644
--- a/lib/Shipwright/Script/Import.pm
+++ b/lib/Shipwright/Script/Import.pm
@@ -59,10 +59,14 @@ sub run {
 
     my $shipwright = Shipwright->new( repository => $self->repository, );
 
+    my $order      = $shipwright->backend->order || []; 
+    my $installed  = { map { $_ => 1 } @$order };
+
     if ( $self->name && !$source ) {
 
         # don't have source specified, use the one in repo
         my $map        = $shipwright->backend->map    || {};
+
         my $source_yml = $shipwright->backend->source || {};
         my $branches   = $shipwright->backend->branches;
 
@@ -125,6 +129,7 @@ sub run {
                 include_dual_lifed     => $self->include_dual_lifed,
                 skip                   => $self->skip,
                 version                => $self->version,
+                installed              => $installed,
                 skip_recommends        => $self->skip_recommends,
                 skip_all_recommends    => $self->skip_all_recommends,
                 skip_all_test_requires => $self->skip_all_test_requires,
diff --git a/lib/Shipwright/Source/Base.pm b/lib/Shipwright/Source/Base.pm
index d1bd9f1..c25c628 100644
--- a/lib/Shipwright/Source/Base.pm
+++ b/lib/Shipwright/Source/Base.pm
@@ -17,7 +17,7 @@ __PACKAGE__->mk_accessors(
       min_perl_version map_path skip map skip_recommends skip_all_recommends
       skip_installed include_dual_lifed
       keep_build_requires name log url_path version_path branches_path version
-      skip_all_test_requires
+      skip_all_test_requires installed
       /
 );
 
@@ -486,18 +486,14 @@ EOF
 
                 my $name = $module;
 
-                if ( $self->_is_skipped($module) ) {
+                if ( $self->_is_skipped($module)
+                    && !$self->_is_installed($module) )
+                {
+
                     # skipped contains all modules imported before,
                     # so we need to check if they are imported ones
-                    unless ( defined $map->{$module}
-                        || defined $url->{$module} )
-                    {
-
-                        # not in the map, meaning it's not been imported before,
-                        # so it's safe to erase it
-                        delete $require->{$type}{$module};
-                        next;
-                    }
+                    delete $require->{$type}{$module};
+                    next;
                 }
                 else {
 
@@ -671,6 +667,21 @@ sub _is_skipped {
     return;
 }
 
+sub _is_installed {
+    my $self   = shift;
+    my $module = shift;
+    my $installed;
+
+    my $name = $module;
+    if ( $module !~ /-/ ) {
+        my $source = Shipwright::Source->new( source => "cpan:$module" );
+        $source->_run;
+        $name = $source->name;
+    }
+
+    return $self->installed->{$name};
+}
+
 sub _copy {
     my $self = shift;
     my %file = @_;

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list