[vhffs-dev] [2044] finished bazaar bots reworking, improved Vhffs::Object:: set_status so that we don' t set and add an history line for the same status update twice (or more), renamed bazaar_public to bazaar_modify

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 2044
Author:   gradator
Date:     2012-02-24 22:09:04 +0100 (Fri, 24 Feb 2012)
Log Message:
-----------
finished bazaar bots reworking, improved Vhffs::Object::set_status so that we don't set and add an history line for the same status update twice (or more), renamed bazaar_public to bazaar_modify

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Object.pm
    trunk/vhffs-api/src/Vhffs/Robots/Bazaar.pm
    trunk/vhffs-robots/Makefile.am

Added Paths:
-----------
    trunk/vhffs-robots/src/bazaar_modify.pl

Removed Paths:
-------------
    trunk/vhffs-robots/src/bazaar_public.pl

Modified: trunk/vhffs-api/src/Vhffs/Object.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Object.pm	2012-02-24 00:01:17 UTC (rev 2043)
+++ trunk/vhffs-api/src/Vhffs/Object.pm	2012-02-24 21:09:04 UTC (rev 2044)
@@ -460,6 +460,7 @@
 =cut
 sub set_status {
 	my ($self, $value) = @_;
+	return if $self->{'state'} == $value;
 	$self->{'state'} = $value;
 
 	if( $value == Vhffs::Constants::WAITING_FOR_VALIDATION ) {

Modified: trunk/vhffs-api/src/Vhffs/Robots/Bazaar.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Bazaar.pm	2012-02-24 00:01:17 UTC (rev 2043)
+++ trunk/vhffs-api/src/Vhffs/Robots/Bazaar.pm	2012-02-24 21:09:04 UTC (rev 2044)
@@ -45,6 +45,7 @@
 	my $bazaar = shift;
 	return undef unless defined $bazaar and $bazaar->get_status == Vhffs::Constants::WAITING_FOR_CREATION;
 
+	my $vhffs = $bazaar->get_main;
 	my $dir = $bazaar->get_dir;
 
 	if( -e $dir ) {
@@ -97,25 +98,13 @@
 	return 1;
 }
 
-sub modify {
-	my $bazaar = shift;
-	return undef unless defined $bazaar and $bazaar->get_status == Vhffs::Constants::WAITING_FOR_MODIFICATION;
-
-	my $dir = $bazaar->get_dir;
-	my $mail_from = $bazaar->get_main->get_config->get_service('bazaar')->{notify_from};
-
-	if( $bazaar->get_ml_name !~ /^\s*$/ ) {
-		# TODO: Bazaar mail on commit
-	}
-
-	return 1;
-}
-
 sub delete {
 	my $bazaar = shift;
 	return undef unless defined $bazaar and $bazaar->get_status == Vhffs::Constants::WAITING_FOR_DELETION;
 
+	my $vhffs = $bazaar->get_main;
 	my $dir = $bazaar->get_dir;
+
 	Vhffs::Robots::archive_targz( $bazaar, $dir );
 
 	File::Path::remove_tree( $dir, { error => \my $errors });
@@ -141,4 +130,32 @@
 	return 1;
 }
 
+sub modify {
+	my $bazaar = shift;
+	return undef unless defined $bazaar and $bazaar->get_status == Vhffs::Constants::WAITING_FOR_MODIFICATION;
+
+	my $vhffs = $bazaar->get_main;
+	my $dir = $bazaar->get_dir;
+	my $mail_from = $bazaar->get_main->get_config->get_service('bazaar')->{notify_from};
+
+	if( $bazaar->get_ml_name !~ /^\s*$/ ) {
+		# TODO: Bazaar mail on commit
+	}
+
+	if( $bazaar->is_public ) {
+		chmod 02775 , $bazaar->get_dir;
+		Vhffs::Robots::vhffs_log( $vhffs, 'Bazaar repository '.$bazaar->get_reponame.' is now public' );
+		$bazaar->add_history( 'Is now public');
+	} else {
+		chmod 02770 , $bazaar->get_dir;
+		Vhffs::Robots::vhffs_log( $vhffs, 'Bazaar repository '.$bazaar->get_reponame.' is now private' );
+		$bazaar->add_history( 'Is now private');
+	}
+
+	$bazaar->set_status( Vhffs::Constants::ACTIVATED );
+	$bazaar->commit;
+
+	return 1;
+}
+
 1;

Modified: trunk/vhffs-robots/Makefile.am
===================================================================
--- trunk/vhffs-robots/Makefile.am	2012-02-24 00:01:17 UTC (rev 2043)
+++ trunk/vhffs-robots/Makefile.am	2012-02-24 21:09:04 UTC (rev 2044)
@@ -64,7 +64,7 @@
 	src/mercurial_public.pl \
 	src/bazaar_create.pl \
 	src/bazaar_delete.pl \
-	src/bazaar_public.pl \
+	src/bazaar_modify.pl \
 	src/user_create.pl \
 	src/user_delete.pl \
 	src/user_group.pl \

Copied: trunk/vhffs-robots/src/bazaar_modify.pl (from rev 2043, trunk/vhffs-robots/src/bazaar_public.pl)
===================================================================
--- trunk/vhffs-robots/src/bazaar_modify.pl	                        (rev 0)
+++ trunk/vhffs-robots/src/bazaar_modify.pl	2012-02-24 21:09:04 UTC (rev 2044)
@@ -0,0 +1,49 @@
+#!%PERL%
+# Copyright (c) vhffs project and its contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright 
+#   notice, this list of conditions and the following disclaimer.
+#2. Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in 
+#   the documentation and/or other materials provided with the 
+#   distribution.
+#3. Neither the name of vhffs nor the names of its contributors 
+#   may be used to endorse or promote products derived from this 
+#   software without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+# POSSIBILITY OF SUCH DAMAGE.
+
+use strict;
+use utf8;
+
+use lib '%VHFFS_LIB_DIR%';
+use Vhffs::Robots::Bazaar;
+
+my $vhffs = init Vhffs::Main;
+exit 1 unless defined $vhffs;
+
+Vhffs::Robots::lock( $vhffs, 'bazaar' );
+
+my $repos = Vhffs::Services::Bazaar::getall( $vhffs, Vhffs::Constants::WAITING_FOR_MODIFICATION );
+foreach ( @{$repos} ) {
+	Vhffs::Robots::Bazaar::modify( $_ );
+}
+
+Vhffs::Robots::unlock( $vhffs, 'bazaar' );
+exit 0;

Deleted: trunk/vhffs-robots/src/bazaar_public.pl
===================================================================
--- trunk/vhffs-robots/src/bazaar_public.pl	2012-02-24 00:01:17 UTC (rev 2043)
+++ trunk/vhffs-robots/src/bazaar_public.pl	2012-02-24 21:09:04 UTC (rev 2044)
@@ -1,71 +0,0 @@
-#!%PERL%
-# Copyright (c) vhffs project and its contributors
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without 
-# modification, are permitted provided that the following conditions 
-# are met:
-#
-# 1. Redistributions of source code must retain the above copyright 
-#   notice, this list of conditions and the following disclaimer.
-#2. Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in 
-#   the documentation and/or other materials provided with the 
-#   distribution.
-#3. Neither the name of vhffs nor the names of its contributors 
-#   may be used to endorse or promote products derived from this 
-#   software without specific prior written permission.
-#
-#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
-#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
-#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
-#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
-#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
-#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
-#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
-# POSSIBILITY OF SUCH DAMAGE.
-
-use strict;
-use utf8;
-
-use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Main;
-use Vhffs::Robots;
-use Vhffs::Robots::Bazaar;
-use Vhffs::Services::Bazaar;
-use Vhffs::Constants;
-
-
-my $vhffs = init Vhffs::Main;
-
-Vhffs::Robots::lock( $vhffs , 'bazaar' );
-
-my $repos = Vhffs::Services::Bazaar::getall( $vhffs , Vhffs::Constants::WAITING_FOR_MODIFICATION );
-foreach my $bazaar ( @{$repos} )
-{
-	if( $bazaar->is_public == 1 ) {
-		chmod 02775 , $bazaar->get_dir;
-		Vhffs::Robots::vhffs_log( $vhffs, sprintf( 'Bazaar status %s is now public' , $bazaar->get_dir ) );
-	} else {
-		chmod 02770 , $bazaar->get_dir;
-		Vhffs::Robots::vhffs_log( $vhffs, sprintf( 'Bazaar status %s is now private' , $bazaar->get_dir ) );
-	}
-
-	Vhffs::Robots::Bazaar::modify( $bazaar );
-	$bazaar->set_status( Vhffs::Constants::ACTIVATED );
-	
-	if( $bazaar->commit < 0 ) {
-		$bazaar->add_history( 'Error while updating repository configuration' );
-	} else {
-		$bazaar->add_history( 'Successfully modify repository configuration' );
-	}
-}
-
-
-Vhffs::Robots::unlock( $vhffs , 'bazaar' );
-
-exit 0;


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/