[Bps-public-commit] r17807 - in Shipwright/trunk: lib/Shipwright/Script
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Sun Jan 18 07:53:25 EST 2009
Author: sunnavy
Date: Sun Jan 18 07:53:23 2009
New Revision: 17807
Modified:
Shipwright/trunk/ (props changed)
Shipwright/trunk/lib/Shipwright/Script/Update.pm
Log:
r18879 at sunnavys-mb: sunnavy | 2009-01-18 17:28:14 +0800
add --as for update cmd
Modified: Shipwright/trunk/lib/Shipwright/Script/Update.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Script/Update.pm (original)
+++ Shipwright/trunk/lib/Shipwright/Script/Update.pm Sun Jan 18 07:53:23 2009
@@ -5,7 +5,9 @@
use Carp;
use base qw/App::CLI::Command Class::Accessor::Fast Shipwright::Script/;
-__PACKAGE__->mk_accessors(qw/all follow builder utility version only_sources/);
+__PACKAGE__->mk_accessors(
+ qw/all follow builder utility version only_sources as/
+);
use Shipwright;
use File::Spec::Functions qw/catdir/;
@@ -25,10 +27,11 @@
'utility' => 'utility',
'version=s' => 'version',
'only-sources' => 'only_sources',
+ 'as=s' => 'as',
);
}
-my ( $shipwright, $map, $source );
+my ( $shipwright, $map, $source, $branches );
sub run {
my $self = shift;
@@ -43,28 +46,9 @@
}
else {
- my $name = shift;
- my $new_source = shift;
- if ($new_source) {
- system(
- "$0 relocate -r "
- . $self->repository
- . (
- $self->log_level ? ( " --log-level " . $self->log_level )
- : ''
- )
- . (
- $self->log_file ? ( " --log-file " . $self->log_file )
- : ''
- )
- . " $name $new_source"
- ) && die "relocate $name to $new_source failed: $!";
- }
-
- confess "need name arg\n" unless $name || $self->all;
-
$map = $shipwright->backend->map || {};
$source = $shipwright->backend->source || {};
+ $branches = $shipwright->backend->branches;
if ( $self->all ) {
my $dists = $shipwright->backend->order || [];
@@ -73,6 +57,41 @@
}
}
else {
+ my $name = shift;
+ confess "need name arg\n" unless $name;
+
+ # die if the specified branch doesn't exist
+ if ( $branches && $self->as ) {
+ confess "$name doesn't have branch "
+ . $self->as
+ . ". please use import cmd instead"
+ unless grep { $_ eq $self->as } @{ $branches->{$name} || [] };
+ }
+
+ my $new_source = shift;
+ if ($new_source) {
+ system(
+ "$0 relocate -r "
+ . $self->repository
+ . (
+ $self->log_level
+ ? ( " --log-level " . $self->log_level )
+ : ''
+ )
+ . (
+ $self->log_file ? ( " --log-file " . $self->log_file )
+ : ''
+ )
+ . (
+ $self->as ? ( " --as " . $self->as )
+ : ''
+ )
+ . " $name $new_source"
+ ) && die "relocate $name to $new_source failed: $!";
+ # renew our $source
+ $source = $shipwright->backend->source || {};
+ }
+
my @dists;
if ( $self->follow ) {
my (%checked);
@@ -100,7 +119,7 @@
for (@dists) {
if ( $self->only_sources ) {
if ( $_ eq $name ) {
- $self->_update( $_, $self->version );
+ $self->_update( $_, $self->version, $self->as );
}
else {
$self->_update($_);
@@ -108,8 +127,9 @@
}
else {
system(
- "$0 import -r " . $self->repository
- . (
+ "$0 import -r "
+ . $self->repository
+ . (
$self->log_level
? ( " --log-level " . $self->log_level )
: ''
@@ -119,6 +139,10 @@
? ( " --log-file " . $self->log_file )
: ''
)
+ . (
+ $self->as ? ( " --as " . $self->as )
+ : ''
+ )
. " --name $_"
);
}
@@ -133,6 +157,7 @@
my $self = shift;
my $name = shift;
my $version = shift;
+ my $as = shift;
if ( $source->{$name} ) {
$shipwright->source(
Shipwright::Source->new(
@@ -182,6 +207,7 @@
comment => "update $name",
overwrite => 1,
version => $version->{$name},
+ as => $as,
);
}
@@ -212,6 +238,7 @@
--builder : update bin/shipwright-builder
--utility : update bin/shipwright-utility
--only-sources : only update sources, no build scripts
+ --as : the branch name
=head1 DESCRIPTION
More information about the Bps-public-commit
mailing list