[Bps-public-commit] r10740 - Shipwright/lib/Shipwright/Backend
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Wed Feb 6 17:47:19 EST 2008
Author: sunnavy
Date: Wed Feb 6 17:47:19 2008
New Revision: 10740
Modified:
Shipwright/lib/Shipwright/Backend/SVK.pm
Shipwright/lib/Shipwright/Backend/SVN.pm
Log:
backend support for overwrite
Modified: Shipwright/lib/Shipwright/Backend/SVK.pm
==============================================================================
--- Shipwright/lib/Shipwright/Backend/SVK.pm (original)
+++ Shipwright/lib/Shipwright/Backend/SVK.pm Wed Feb 6 17:47:19 2008
@@ -55,13 +55,13 @@
'source_tcsh',
File::Spec->catfile( $dir, 'bin', 'shipwright-builder' ) => 'builder',
File::Spec->catfile( $dir, 'bin', 'shipwright-utility' ) => 'utility',
- File::Spec->catfile( $dir, 't', 'test' ) => 'null',
+ File::Spec->catfile( $dir, 't', 'test' ) => 'null',
File::Spec->catfile( $dir, 'shipwright', 'order.yml' ) => 'null',
);
for ( keys %map ) {
open my $fh, '>', $_ or die "can't open file $_: $!";
- print $fh Shipwright::Backend->make_script($map{$_});
+ print $fh Shipwright::Backend->make_script( $map{$_} );
close $fh;
}
@@ -75,7 +75,7 @@
for (
'bin/shipwright-builder', 'bin/shipwright-utility',
'etc/shipwright-perl-wrapper', 'etc/shipwright-script-wrapper',
- 't/test', 'etc/shipwright-utility',
+ 't/test', 'etc/shipwright-utility',
)
{
$self->propset(
@@ -102,17 +102,38 @@
unless ( $args{_initialize} || $args{_extra_tests} ) {
if ( $args{build_script} ) {
- $self->delete("scripts/$name");
- $self->log->info(
- "import $args{source}'s scripts to " . $self->repository );
+ if ( $self->info("scripts/$name") && not $args{overwrite} ) {
+ $self->log->warn(
+"path scripts/$name alreay exists, need to set overwrite arg to overwrite"
+ );
+ }
+ else {
+ $self->delete("scripts/$name");
+ $self->log->info(
+ "import $args{source}'s scripts to " . $self->repository );
+ Shipwright::Util->run(
+ $self->_cmd( import => %args, name => $name ) );
+ }
}
else {
- $self->delete("dists/$name");
- $self->log->info( "import $args{source} to " . $self->repository );
- $self->_add_to_order( source => $args{source} );
+ if ( $self->info("dists/$name") && not $args{overwrite} ) {
+ $self->log->warn(
+"path dists/$name alreay exists, need to set overwrite arg to overwrite"
+ );
+ }
+ else {
+ $self->delete("dists/$name");
+ $self->log->info(
+ "import $args{source} to " . $self->repository );
+ $self->_add_to_order( source => $args{source} );
+ Shipwright::Util->run(
+ $self->_cmd( import => %args, name => $name ) );
+ }
}
}
- Shipwright::Util->run( $self->_cmd( import => %args, name => $name ) );
+ else {
+ Shipwright::Util->run( $self->_cmd( import => %args, name => $name ) );
+ }
}
=head2 export
@@ -157,8 +178,9 @@
my $self = shift;
my %args = @_;
$self->log->info( 'commit ' . $args{path} );
-# have to omit the failure since we will get error if nothing need to commit,
-# which's harmless
+
+ # have to omit the failure since we will get error if nothing need to commit,
+ # which's harmless
Shipwright::Util->run( $self->_cmd( commit => @_ ), 1 );
}
@@ -282,8 +304,8 @@
my @dists = @{ $args{for_dists} || [] };
unless (@dists) {
- my ($out) =
- Shipwright::Util->run( [ 'svk', 'ls', $self->repository . '/scripts' ] );
+ my ($out) = Shipwright::Util->run(
+ [ 'svk', 'ls', $self->repository . '/scripts' ] );
my $sep = $/;
@dists = split /$sep/, $out;
chomp @dists;
@@ -315,8 +337,7 @@
my $dist = $args{dist};
my ($string) = Shipwright::Util->run(
- [ 'svk', 'cat', $self->repository . "/scripts/$dist/require.yml" ], 1
- );
+ [ 'svk', 'cat', $self->repository . "/scripts/$dist/require.yml" ], 1 );
my $req = Shipwright::Util::Load($string) || {};
if ( $req->{requires} ) {
@@ -393,6 +414,7 @@
my ( $info, $err ) =
Shipwright::Util->run( $self->_cmd( info => path => $path ), 1 );
$self->log->warn($err) if $err;
+ return if $info =~ /not exist/;
return $info;
}
@@ -405,7 +427,8 @@
sub propset {
my $self = shift;
my %args = @_;
- my ( $info, $err ) = Shipwright::Util->run( $self->_cmd( propset => %args ) );
+ my ( $info, $err ) =
+ Shipwright::Util->run( $self->_cmd( propset => %args ) );
$self->log->warn($err) if $err;
}
Modified: Shipwright/lib/Shipwright/Backend/SVN.pm
==============================================================================
--- Shipwright/lib/Shipwright/Backend/SVN.pm (original)
+++ Shipwright/lib/Shipwright/Backend/SVN.pm Wed Feb 6 17:47:19 2008
@@ -61,7 +61,7 @@
for ( keys %map ) {
open my $fh, '>', $_ or die "can't open file $_: $!";
- print $fh Shipwright::Backend->make_script($map{$_});
+ print $fh Shipwright::Backend->make_script( $map{$_} );
close $fh;
}
@@ -76,7 +76,7 @@
for (
'bin/shipwright-builder', 'bin/shipwright-utility',
'etc/shipwright-perl-wrapper', 'etc/shipwright-script-wrapper',
- 't/test', 'etc/shipwright-utility',
+ 't/test', 'etc/shipwright-utility',
)
{
$self->propset(
@@ -105,20 +105,42 @@
if ( $args{_extra_tests} ) {
$self->delete("t/extra");
$self->log->info( "import extra tests to " . $self->repository );
+ Shipwright::Util->run(
+ $self->_cmd( import => %args, name => $name ) );
}
-
elsif ( $args{build_script} ) {
- $self->delete("scripts/$name");
- $self->log->info(
- "import $args{source}'s scripts to " . $self->repository );
+ if ( $self->info("scripts/$name") && not $args{overwrite} ) {
+ $self->log->warn(
+"path scripts/$name alreay exists, need to set overwrite arg to overwrite"
+ );
+ }
+ else {
+ $self->delete("scripts/$name");
+ $self->log->info(
+ "import $args{source}'s scripts to " . $self->repository );
+ Shipwright::Util->run(
+ $self->_cmd( import => %args, name => $name ) );
+ }
}
else {
- $self->delete("dists/$name");
- $self->log->info( "import $args{source} to " . $self->repository );
- $self->_add_to_order( source => $args{source} );
+ if ( $self->info("dists/$name") && not $args{overwrite} ) {
+ $self->log->warn(
+"path dists/$name alreay exists, need to set overwrite arg to overwrite"
+ );
+ }
+ else {
+ $self->delete("dists/$name");
+ $self->log->info(
+ "import $args{source} to " . $self->repository );
+ $self->_add_to_order( source => $args{source} );
+ Shipwright::Util->run(
+ $self->_cmd( import => %args, name => $name ) );
+ }
}
}
- Shipwright::Util->run( $self->_cmd( import => %args, name => $name ) );
+ else {
+ Shipwright::Util->run( $self->_cmd( import => %args, name => $name ) );
+ }
}
=head2 export
@@ -171,7 +193,7 @@
my $self = shift;
my $type = shift;
my %args = @_;
- $args{path} ||= '';
+ $args{path} ||= '';
$args{comment} ||= '';
for ( @{ $REQUIRE_OPTIONS{$type} } ) {
@@ -279,8 +301,8 @@
my @dists = @{ $args{for_dists} || [] };
unless (@dists) {
- my ($out) =
- Shipwright::Util->run( [ 'svn', 'ls', $self->repository . '/scripts' ] );
+ my ($out) = Shipwright::Util->run(
+ [ 'svn', 'ls', $self->repository . '/scripts' ] );
my $sep = $/;
@dists = split /$sep/, $out;
chomp @dists;
More information about the Bps-public-commit
mailing list