[vhffs-dev] [1569] Added support for Mercurial repositories. |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 1569
Author: guillaumito
Date: 2010-03-20 00:26:29 +0100 (Sat, 20 Mar 2010)
Log Message:
-----------
Added support for Mercurial repositories.
Everyting should be working except commit hook to send mails.
(will add that later)
Modified Paths:
--------------
trunk/vhffs-api/src/Vhffs/Constants.pm
trunk/vhffs-api/src/Vhffs/Functions.pm
trunk/vhffs-api/src/Vhffs/Makefile.am
trunk/vhffs-api/src/Vhffs/ObjectFactory.pm
trunk/vhffs-api/src/Vhffs/Panel/Admin.pm
trunk/vhffs-api/src/Vhffs/Panel/Main.pm
trunk/vhffs-api/src/Vhffs/Panel/Menu.pm
trunk/vhffs-backend/conf/vhffs.conf.dist.in
trunk/vhffs-backend/src/pgsql/initdb.sql.in
trunk/vhffs-panel/Makefile.am
trunk/vhffs-panel/templates/Makefile.am
trunk/vhffs-robots/Makefile.am
Added Paths:
-----------
trunk/vhffs-api/src/Vhffs/Panel/Mercurial.pm
trunk/vhffs-api/src/Vhffs/Robots/Mercurial.pm
trunk/vhffs-api/src/Vhffs/Services/Mercurial.pm
trunk/vhffs-panel/admin/mercurial/
trunk/vhffs-panel/admin/mercurial/index.pl
trunk/vhffs-panel/admin/mercurial/list.pl
trunk/vhffs-panel/admin/mercurial/search.pl
trunk/vhffs-panel/mercurial/
trunk/vhffs-panel/mercurial/create.pl
trunk/vhffs-panel/mercurial/delete.pl
trunk/vhffs-panel/mercurial/index.pl
trunk/vhffs-panel/mercurial/prefs.pl
trunk/vhffs-panel/templates/admin/mercurial/
trunk/vhffs-panel/templates/admin/mercurial/part.tmpl
trunk/vhffs-panel/templates/admin/mercurial/search.tmpl
trunk/vhffs-panel/templates/mercurial/
trunk/vhffs-panel/templates/mercurial/create.tmpl
trunk/vhffs-panel/templates/mercurial/prefs.tmpl
trunk/vhffs-panel/templates/mercurial/user_part.tmpl
trunk/vhffs-robots/src/mercurial_create.pl
trunk/vhffs-robots/src/mercurial_delete.pl
trunk/vhffs-robots/src/mercurial_public.pl
Modified: trunk/vhffs-api/src/Vhffs/Constants.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Constants.pm 2010-03-19 07:02:20 UTC (rev 1568)
+++ trunk/vhffs-api/src/Vhffs/Constants.pm 2010-03-19 23:26:29 UTC (rev 1569)
@@ -72,6 +72,7 @@
TYPE_CVS => 40,
TYPE_SVN => 41,
TYPE_GIT => 42,
+ TYPE_MERCURIAL => 43,
TYPE_DNS => 50,
TYPE_MAIL => 60,
TYPE_ML => 61,
Modified: trunk/vhffs-api/src/Vhffs/Functions.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Functions.pm 2010-03-19 07:02:20 UTC (rev 1568)
+++ trunk/vhffs-api/src/Vhffs/Functions.pm 2010-03-19 23:26:29 UTC (rev 1569)
@@ -81,6 +81,7 @@
$TYPES_STRINGS[Vhffs::Constants::TYPE_CVS] = 'CVS Repository';
$TYPES_STRINGS[Vhffs::Constants::TYPE_SVN] = 'SVN Repository';
$TYPES_STRINGS[Vhffs::Constants::TYPE_GIT] = 'GIT Repository';
+$TYPES_STRINGS[Vhffs::Constants::TYPE_MERCURIAL] = 'Mercurial Repository';
$TYPES_STRINGS[Vhffs::Constants::TYPE_DNS] = 'Domain Name';
$TYPES_STRINGS[Vhffs::Constants::TYPE_MAIL] = 'Mail Domain';
$TYPES_STRINGS[Vhffs::Constants::TYPE_ML] = 'Mailing List';
Modified: trunk/vhffs-api/src/Vhffs/Makefile.am
===================================================================
--- trunk/vhffs-api/src/Vhffs/Makefile.am 2010-03-19 07:02:20 UTC (rev 1568)
+++ trunk/vhffs-api/src/Vhffs/Makefile.am 2010-03-19 23:26:29 UTC (rev 1569)
@@ -30,6 +30,7 @@
Panel/MailingList.pm \
Panel/Main.pm \
Panel/Menu.pm \
+ Panel/Mercurial.pm \
Panel/Mysql.pm \
Panel/Object.pm \
Panel/Pgsql.pm \
@@ -46,6 +47,7 @@
Robots/Group.pm \
Robots/Mail.pm \
Robots/Mailing.pm \
+ Robots/Mercurial.pm \
Robots/Mysql.pm \
Robots/Pgsql.pm \
Robots/Repository.pm \
@@ -62,6 +64,7 @@
Services/Newsletter.pm \
Services/MailUser.pm \
Services/MailGroup.pm \
+ Services/Mercurial.pm \
Services/Mysql.pm \
Services/Pgsql.pm \
Services/Repository.pm \
Modified: trunk/vhffs-api/src/Vhffs/ObjectFactory.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/ObjectFactory.pm 2010-03-19 07:02:20 UTC (rev 1568)
+++ trunk/vhffs-api/src/Vhffs/ObjectFactory.pm 2010-03-19 23:26:29 UTC (rev 1569)
@@ -63,6 +63,7 @@
$OBJECTS_BY_TYPE[Vhffs::Constants::TYPE_CVS] = 'Vhffs::Services::Cvs';
$OBJECTS_BY_TYPE[Vhffs::Constants::TYPE_SVN] = 'Vhffs::Services::Svn';
$OBJECTS_BY_TYPE[Vhffs::Constants::TYPE_GIT] = 'Vhffs::Services::Git';
+$OBJECTS_BY_TYPE[Vhffs::Constants::TYPE_MERCURIAL] = 'Vhffs::Services::Mercurial';
$OBJECTS_BY_TYPE[Vhffs::Constants::TYPE_DNS] = 'Vhffs::Services::DNS';
$OBJECTS_BY_TYPE[Vhffs::Constants::TYPE_MAIL] = 'Vhffs::Services::Mail';
$OBJECTS_BY_TYPE[Vhffs::Constants::TYPE_ML] = 'Vhffs::Services::MailingList';
Modified: trunk/vhffs-api/src/Vhffs/Panel/Admin.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Admin.pm 2010-03-19 07:02:20 UTC (rev 1568)
+++ trunk/vhffs-api/src/Vhffs/Panel/Admin.pm 2010-03-19 23:26:29 UTC (rev 1569)
@@ -226,6 +226,24 @@
return { CATNAME => gettext( 'Git Admin' ), ITEMS => $items, CATTYPE => 'git' };
}
+
+=head2 get_mercurial_category
+
+ Vhffs::Panel::Admin::get_mercurial_category;
+
+Returns a hashref (CATNAME, ITEM) containing mercurial's administration
+items.
+
+=cut
+
+sub get_mercurial_category {
+ my $items = [
+ { LINK => '/admin/mercurial/list.pl', LABEL => gettext( 'List all Mercurial repos' ) },
+ { LINK => '/admin/mercurial/search.pl', LABEL => gettext( 'Search for a Mercurial repository' ) }
+ ];
+ return { CATNAME => gettext( 'Mercurial Admin' ), ITEMS => $items, CATTYPE => 'mercurial' };
+}
+
=head2 get_mysql_category
Vhffs::Panel::Admin::get_mysql_category;
@@ -365,17 +383,18 @@
push @$categories, get_admin_category;
push @$categories, get_user_category;
push @$categories, get_group_category;
- push @$categories, get_web_category if($config->get_service_availability('web'));
- push @$categories, get_mysql_category if($config->get_service_availability('mysql'));
- push @$categories, get_pgsql_category if($config->get_service_availability('pgsql'));
- push @$categories, get_cvs_category if($config->get_service_availability('cvs'));
- push @$categories, get_svn_category if($config->get_service_availability('svn'));
- push @$categories, get_dns_category if($config->get_service_availability('dns'));
- push @$categories, get_git_category if($config->get_service_availability('git'));
- push @$categories, get_mail_category if($config->get_service_availability('mail'));
- push @$categories, get_mailing_category if($config->get_service_availability('mailinglist'));
- push @$categories, get_repo_category if($config->get_service_availability('repository'));
- push @$categories, get_cron_category if($config->get_service_availability('cron'));
+ push @$categories, get_web_category if($config->get_service_availability('web'));
+ push @$categories, get_mysql_category if($config->get_service_availability('mysql'));
+ push @$categories, get_pgsql_category if($config->get_service_availability('pgsql'));
+ push @$categories, get_cvs_category if($config->get_service_availability('cvs'));
+ push @$categories, get_svn_category if($config->get_service_availability('svn'));
+ push @$categories, get_dns_category if($config->get_service_availability('dns'));
+ push @$categories, get_git_category if($config->get_service_availability('git'));
+ push @$categories, get_mercurial_category if($config->get_service_availability('mercurial'));
+ push @$categories, get_mail_category if($config->get_service_availability('mail'));
+ push @$categories, get_mailing_category if($config->get_service_availability('mailinglist'));
+ push @$categories, get_repo_category if($config->get_service_availability('repository'));
+ push @$categories, get_cron_category if($config->get_service_availability('cron'));
push @$categories, get_tag_category;
return $categories;
@@ -399,17 +418,18 @@
push @$categories, get_modo_category;
push @$categories, get_user_category;
push @$categories, get_group_category;
- push @$categories, get_web_category if($config->get_service_availability('web'));
- push @$categories, get_mysql_category if($config->get_service_availability('mysql'));
- push @$categories, get_pgsql_category if($config->get_service_availability('pgsql'));
- push @$categories, get_cvs_category if($config->get_service_availability('cvs'));
- push @$categories, get_svn_category if($config->get_service_availability('svn'));
- push @$categories, get_git_category if($config->get_service_availability('git'));
- push @$categories, get_dns_category if($config->get_service_availability('dns'));
- push @$categories, get_mail_category if($config->get_service_availability('mail'));
- push @$categories, get_mailing_category if($config->get_service_availability('mailinglist'));
- push @$categories, get_repo_category if($config->get_service_availability('repository'));
- push @$categories, get_cron_category if($config->get_service_availability('cron'));
+ push @$categories, get_web_category if($config->get_service_availability('web'));
+ push @$categories, get_mysql_category if($config->get_service_availability('mysql'));
+ push @$categories, get_pgsql_category if($config->get_service_availability('pgsql'));
+ push @$categories, get_cvs_category if($config->get_service_availability('cvs'));
+ push @$categories, get_svn_category if($config->get_service_availability('svn'));
+ push @$categories, get_git_category if($config->get_service_availability('git'));
+ push @$categories, get_mercurial_category if($config->get_service_availability('mercurial'));
+ push @$categories, get_dns_category if($config->get_service_availability('dns'));
+ push @$categories, get_mail_category if($config->get_service_availability('mail'));
+ push @$categories, get_mailing_category if($config->get_service_availability('mailinglist'));
+ push @$categories, get_repo_category if($config->get_service_availability('repository'));
+ push @$categories, get_cron_category if($config->get_service_availability('cron'));
push @$categories, get_tag_category;
return $categories;
Modified: trunk/vhffs-api/src/Vhffs/Panel/Main.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Main.pm 2010-03-19 07:02:20 UTC (rev 1568)
+++ trunk/vhffs-api/src/Vhffs/Panel/Main.pm 2010-03-19 23:26:29 UTC (rev 1569)
@@ -33,6 +33,7 @@
use Vhffs::Panel::Repository;
use Vhffs::Panel::Svn;
use Vhffs::Panel::Git;
+use Vhffs::Panel::Mercurial;
use Vhffs::Panel::Web;
use Vhffs::Panel::Cron;
@@ -585,6 +586,11 @@
$services_list .= $panel->create_service_index('git', $git)->output;
}
+ if($config->get_service_availability('mercurial')) {
+ my $mercurial = Vhffs::Panel::Mercurial::getall_per_group( $vhffs, $gid );
+ $services_list .= $panel->create_service_index('mercurial', $mercurial)->output;
+ }
+
if($config->get_service_availability('mailinglist')) {
my $ml = Vhffs::Panel::MailingList::getall_per_group( $vhffs, $gid );
$services_list .= $panel->create_service_index('mailinglist', $ml)->output;
@@ -789,6 +795,7 @@
repository => 'Download repositories',
svn => 'SVN repositories',
git => 'Git repositories',
+ mercurial => 'Mercurial repositories',
web => 'Webareas',
cron => 'Cron jobs',
);
Modified: trunk/vhffs-api/src/Vhffs/Panel/Menu.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Menu.pm 2010-03-19 07:02:20 UTC (rev 1568)
+++ trunk/vhffs-api/src/Vhffs/Panel/Menu.pm 2010-03-19 23:26:29 UTC (rev 1569)
@@ -70,6 +70,7 @@
push @$items, {path => 'cvs', label => gettext('CVS') } if( $config->get_service_availability('cvs') );
push @$items, {path => 'svn', label => gettext('SVN') } if( $config->get_service_availability('svn') );
push @$items, {path => 'git', label => gettext('GIT') } if( $config->get_service_availability('git') );
+ push @$items, {path => 'mercurial', label => gettext('Mercurial') } if( $config->get_service_availability('mercurial') );
push @$items, {path => 'dns', label => gettext('Domain names') } if( $config->get_service_availability('dns') );
push @$items, {path => 'repository', label => gettext('Dl repos') } if( $config->get_service_availability('repository') );
push @$items, {path => 'mail', label => gettext('Mail') } if( $config->get_service_availability('mail') );
@@ -120,6 +121,7 @@
push @$items, {path => 'admin/cvs', label => gettext('CVS') } if( $config->get_service_availability('cvs') );
push @$items, {path => 'admin/svn', label => gettext('SVN') } if( $config->get_service_availability('svn') );
push @$items, {path => 'admin/git', label => gettext('GIT') } if( $config->get_service_availability('git') );
+ push @$items, {path => 'admin/mercurial', label => gettext('Mercurial') } if( $config->get_service_availability('mercurial') );
push @$items, {path => 'admin/dns', label => gettext('Domain names') } if( $config->get_service_availability('dns') );
push @$items, {path => 'admin/repository', label => gettext('Dl repos') } if( $config->get_service_availability('repository') );
push @$items, {path => 'admin/mail', label => gettext('Mail') } if( $config->get_service_availability('mail') );
Added: trunk/vhffs-api/src/Vhffs/Panel/Mercurial.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Mercurial.pm (rev 0)
+++ trunk/vhffs-api/src/Vhffs/Panel/Mercurial.pm 2010-03-19 23:26:29 UTC (rev 1569)
@@ -0,0 +1,140 @@
+#!%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;
+
+package Vhffs::Panel::Mercurial;
+
+use DBI;
+use POSIX qw(locale_h);
+use HTML::Template;
+use locale;
+use Locale::gettext;
+use CGI;
+use CGI::Session;
+use Vhffs::User;
+use Vhffs::Main;
+use Vhffs::Acl;
+use Vhffs::Services::Mercurial;
+use Vhffs::Panel::Main;
+use Vhffs::Constants;
+use Vhffs::Functions;
+
+
+=pod
+
+=head2 getall_per_group
+
+ $mercurial = Vhffs::Panel::Mercurial::getall_per_group($vhffs, $gid);
+
+Returns an array of hashrefs (oid, displayname, active, state (localized string)) of all mercurial repos owned by
+a given group.
+
+=cut
+
+
+sub getall_per_group
+{
+ my ( $main, $gid ) = @_;
+
+ my $dbh = $main->get_db_object;
+ my $sql = 'SELECT s.object_id AS oid, s.reponame AS displayname, o.state FROM vhffs_mercurial s INNER JOIN vhffs_object o ON s.object_id = o.object_id WHERE o.owner_gid = ? ORDER BY s.reponame';
+ my $sth = $dbh->prepare($sql) or return -1;
+ $sth->execute($gid) or return -2;
+ my $mercurial = [];
+ while(my $s = $sth->fetchrow_hashref) {
+ $s->{active} = ($s->{state} == Vhffs::Constants::ACTIVATED);
+ $s->{refused} = ($s->{state} == Vhffs::Constants::VALIDATION_REFUSED);
+ $s->{state} = Vhffs::Functions::status_string_from_status_id($s->{state});
+ push @$mercurial, $s;
+ }
+ return $mercurial;
+}
+
+sub get_repos_per_group {
+ my ($main, $gid, $public_only) = @_;
+ $public_only = 1 unless(defined $public_only);
+
+ my $dbh = $main->get_db_object;
+ my $sql = 'SELECT g.reponame, o.description FROM vhffs_mercurial g INNER JOIN vhffs_object o ON o.object_id = g.object_id '.
+ 'WHERE '.($public_only ? 'public = 1 AND ' : '').'o.owner_gid = ? AND o.state = ?';
+ return $dbh->selectall_arrayref($sql, { Slice => {} }, $gid, Vhffs::Constants::ACTIVATED);
+}
+
+
+sub search {
+ my ($main, $name) = @_;
+
+ my $sql;
+ my @params;
+ my $mercurials = [];
+
+ if( defined $name ) {
+ $sql = 'SELECT s.reponame AS mercurialroot, g.groupname, o.state FROM vhffs_mercurial s INNER JOIN vhffs_object o ON o.object_id=s.object_id INNER JOIN vhffs_groups g ON g.gid = o.owner_gid WHERE s.reponame LIKE ?';
+ push(@params, '%'.lc($name).'%');
+ } else {
+ $sql = 'SELECT s.reponame AS mercurialroot, g.groupname, o.state FROM vhffs_mercurial s INNER JOIN vhffs_object o ON o.object_id=s.object_id INNER JOIN vhffs_groups g ON g.gid = o.owner_gid';
+ }
+
+ my $dbh = $main->get_db_object();
+ my $sth = $dbh->prepare($sql) or return undef;
+
+ return undef unless($sth->execute(@params));
+
+ while(my $s = $sth->fetchrow_hashref('NAME_lc')) {
+ $s->{state} = Vhffs::Functions::status_string_from_status_id($s->{state});
+ push(@$mercurials, $s);
+ }
+
+ return $mercurials;
+}
+
+
+
+sub create_mercurial
+{
+ my ($main, $repo, $description, $user, $group) = @_;
+
+ return -1 unless( defined $user );
+ return -2 unless( defined $group );
+
+ my $mercurial = Vhffs::Services::Mercurial::create( $main, $repo, $description, $user, $group );
+
+ return -1 unless( defined $mercurial );
+
+ return ( -3 ) if ( Vhffs::Acl::add_acl( $user , $mercurial , Vhffs::Constants::ACL_DELETE , $main ) < 0 );
+ return ( -3 ) if( Vhffs::Acl::add_acl( $group , $mercurial , Vhffs::Constants::ACL_VIEW , $main ) < 0 );
+
+ return $mercurial;
+}
+
+1;
Added: trunk/vhffs-api/src/Vhffs/Robots/Mercurial.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Mercurial.pm (rev 0)
+++ trunk/vhffs-api/src/Vhffs/Robots/Mercurial.pm 2010-03-19 23:26:29 UTC (rev 1569)
@@ -0,0 +1,110 @@
+#!%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;
+
+package Vhffs::Robots::Mercurial;
+
+use Vhffs::Services::Mercurial;
+use Vhffs::Constants;
+use Vhffs::Functions;
+
+sub create_repo
+{
+ my $mercurial = shift;
+ return -1 unless defined $mercurial;
+ return -1 if $mercurial->get_status != Vhffs::Constants::WAITING_FOR_CREATION;
+
+ my $dir = $mercurial->get_dir;
+
+ if( -e $dir ) {
+ $mercurial->set_status( Vhffs::Constants::CREATING_ERROR );
+ $mercurial->commit();
+ $mercurial->add_history('Error, directory of this mercurial repository already exists! Administrators must fix the problem.');
+ return -1;
+ }
+
+ Vhffs::Functions::create_dir( $dir );
+ Vhffs::Functions::chmod_recur( $dir , 0664 , 02775 );
+ Vhffs::Functions::change_owner_recur( $dir , $mercurial->get_owner_uid , $mercurial->get_owner_gid );
+ $mercurial->add_history('Ok, robots find the empty directory and will create mercurial repository');
+
+ system('cd '.$dir.' && hg init > /dev/null');
+
+ unless( -d $dir.'/.hg' ) {
+ $mercurial->set_status( Vhffs::Constants::CREATING_ERROR );
+ $mercurial->commit();
+ $mercurial->add_history('Error, nothing was created after calling the mercurial binary, something is wrong.');
+ return -1;
+ }
+
+ Vhffs::Functions::chmod_recur( $dir , 0664 , 02775 );
+ Vhffs::Functions::change_owner_recur( $dir , $mercurial->get_owner_uid , $mercurial->get_owner_gid );
+
+ $mercurial->add_history('The Robots created the mercurial repository');
+ $mercurial->set_status( Vhffs::Constants::ACTIVATED );
+ $mercurial->commit;
+
+ return 0;
+}
+
+sub change_conf {
+ my $mercurial = shift;
+ return -1 unless defined $mercurial;
+
+ my $dir = $mercurial->get_dir;
+ my $mail_from = $mercurial->get_main->get_config->get_service('mercurial')->{notify_from};
+
+ if( $mercurial->get_ml_name !~ /^\s*$/ ) {
+ }
+
+ return 0;
+}
+
+sub delete_repo
+{
+ use File::Path;
+ use File::Basename;
+ my $mercurial = shift;
+ return -1 unless defined $mercurial;
+
+ # Remove Mercurial dir and group dir if empty
+ my $dir = $mercurial->get_dir;
+ File::Path::rmtree($dir) if(-d $dir);
+ my $groupdir = dirname($dir);
+ rmdir($groupdir);
+
+ return 0;
+}
+
+
+1;
Added: trunk/vhffs-api/src/Vhffs/Services/Mercurial.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Mercurial.pm (rev 0)
+++ trunk/vhffs-api/src/Vhffs/Services/Mercurial.pm 2010-03-19 23:26:29 UTC (rev 1569)
@@ -0,0 +1,264 @@
+#!%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.
+
+# This file is a part of VHFFS4 Hosting Platform
+# Please respect the licence of this file and the whole software
+
+use strict;
+use utf8;
+
+package Vhffs::Services::Mercurial;
+
+use base qw(Vhffs::Object);
+use Vhffs::Group;
+use DBI;
+
+sub check_name($) {
+ my $name = shift;
+ return ($name =~ /^[a-z0-9]+\/[a-z0-9]{3,64}$/);
+}
+
+sub delete
+{
+ my $self = shift;
+ my $query;
+ my $request;
+
+ $query = "DELETE FROM vhffs_mercurial WHERE object_id='".$self->{'object_id'}."'";
+ $request = $self->{'db'}->prepare($query);
+ $request->execute or return -1;
+
+ return -1 if( $self->SUPER::delete < 0 );
+}
+
+sub create
+{
+ my ($main, $rname, $description, $user, $group) = @_;
+
+ return undef unless(defined($user) && defined($group));
+ return undef unless(check_name($rname));
+
+ my $mercurial;
+
+ my $dbh = $main->get_db_object();
+ local $dbh->{RaiseError} = 1;
+ local $dbh->{PrintError} = 0;
+ $dbh->begin_work;
+
+ eval {
+ my $parent = Vhffs::Object::create($main, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_MERCURIAL);
+
+ die('Unable to create parent object') unless(defined $parent);
+
+ my $sql = 'INSERT INTO vhffs_mercurial(reponame, public, ml_name, object_id) VALUES(?, 1, \'\', ?)';
+ my $sth = $dbh->prepare($sql);
+ $sth->execute($rname, $parent->get_oid) or return undef;
+
+ $dbh->commit;
+ $mercurial = get_by_reponame($main, $rname);
+ };
+
+ if($@) {
+ warn "Unable to create mercurial repository $rname: $@\n";
+ $dbh->rollback;
+ }
+
+ return $mercurial;
+}
+
+sub get_by_reponame($$) {
+ my ($main, $reponame) = @_;
+ my @params;
+
+ my $sql = 'SELECT s.mercurial_id, s.reponame, o.owner_uid, o.owner_gid, s.public, s.ml_name, o.object_id, o.date_creation, o.description, o.state FROM vhffs_mercurial s INNER JOIN vhffs_object o ON o.object_id = s.object_id WHERE s.reponame = ?';
+
+ my $dbh = $main->get_db_object();
+
+ return undef unless(@params = $dbh->selectrow_array($sql, undef, $reponame));
+
+ return _new Vhffs::Services::Mercurial($main, @params);
+
+}
+
+=head2 fill_object
+
+See C<Vhffs::Object::fill_object>.
+
+=cut
+
+sub fill_object {
+ my ($class, $obj) = @_;
+ my $sql = q{SELECT mercurial_id, reponame, public, ml_name FROM vhffs_mercurial
+ WHERE object_id = ?};
+ return $class->SUPER::_fill_object($obj, $sql);
+}
+
+sub _new
+{
+ my ($class, $main, $mercurial_id, $reponame, $owner_uid, $owner_gid, $public, $ml_name, $oid, $date_creation, $description, $state) = @_;
+
+ my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_MERCURIAL);
+ return undef unless(defined $self);
+
+ $self->{mercurial_id} = $mercurial_id;
+ $self->{reponame} = $reponame;
+ $self->{public} = $public;
+ $self->{ml_name} = $ml_name;
+
+ return $self;
+}
+
+sub commit
+{
+ my $self = shift;
+
+ my $dbh = $self->get_db_object;
+ my $sql = 'UPDATE vhffs_mercurial SET public = ?, ml_name = ? WHERE mercurial_id = ?';
+ $dbh->do($sql, undef, $self->{public}, $self->{ml_name}, $self->{mercurial_id});
+
+ $self->SUPER::commit;
+}
+
+sub set_public
+{
+ my $self = shift;
+ $self->{'public'} = 1;
+}
+
+sub set_private
+{
+ my $self = shift;
+ $self->{'public'} = 0;
+}
+
+sub set_ml_name {
+ my ($self, $ml_name) = @_;
+ return -1 unless(Vhffs::Functions::valid_mail($ml_name) || $ml_name =~ /^\s*$/);
+ $self->{ml_name} = $ml_name;
+}
+
+sub is_public
+{
+ my $self = shift;
+
+ return -1 if( ! defined $self->{'public'} );
+
+ if( $self->{'public'} == 1 ) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+sub get_ml_name {
+ my $self = shift;
+ return $self->{ml_name};
+}
+
+sub get_reponame
+{
+ my $self = shift;
+ return $self->{'reponame'};
+}
+
+sub get_label
+{
+ my $self = shift;
+ return $self->{reponame};
+}
+
+sub getall
+{
+ my ($vhffs, $state, $name, $group) = @_;
+
+ my $mercurial = [];
+ my @params;
+
+ my $sql = 'SELECT s.mercurial_id, s.reponame, o.owner_uid, o.owner_gid, s.public, s.ml_name, o.object_id, o.date_creation, o.description, o.state FROM vhffs_mercurial s, vhffs_object o WHERE o.object_id = s.object_id';
+
+
+ if(defined $state) {
+ $sql .= ' AND o.state = ?';
+ push(@params, $state);
+ }
+ if(defined $name) {
+ $sql .= ' AND s.name = ?';
+ push(@params, $name);
+ }
+ if(defined($group)) {
+ $sql .= ' AND o.owner_gid = ?';
+ push(@params, $group->get_gid);
+ }
+ $sql .= ' ORDER BY s.reponame';
+
+ my $dbh = $vhffs->get_db_object();
+
+ my $sth = $dbh->prepare($sql);
+ $sth->execute(@params) or die($sql) ; #return undef;
+
+ while(my $s = $sth->fetchrow_arrayref()) {
+ push(@$mercurial, _new Vhffs::Services::Mercurial($vhffs, @$s));
+ }
+ return $mercurial;
+}
+
+sub getall_by_group
+{
+ my ($vhffs, $group) = @_;
+
+ my $mercurial = [];
+ my @params;
+
+ return undef unless( defined $group );
+
+ my $sql = 'SELECT s.mercurial_id, s.reponame, o.owner_uid, o.owner_gid, s.public, o.object_id, o.date_creation, o.description, o.state FROM vhffs_mercurial s INNER
+ JOIN vhffs_object o ON o.object_id = s.object_id WHERE o.owner_gid = ? ORDER BY s.reponame';
+
+ my $dbh = $vhffs->get_db_object();
+
+ my $sth = $dbh->prepare($sql);
+ $sth->execute($group->get_gid) or return undef;
+
+ while(my $s = $sth->fetchrow_arrayref()) {
+ push(@$mercurial, _new Vhffs::Services::Mercurial($vhffs, @$s));
+ }
+ return $mercurial;
+}
+
+sub get_dir
+{
+ my $self = shift;
+ return undef if( ! defined $self );
+
+ return( $self->{'main'}->get_config->get_datadir . "/mercurial/mercurialroot/" . $self->get_reponame );
+}
+
+1;
Modified: trunk/vhffs-backend/conf/vhffs.conf.dist.in
===================================================================
--- trunk/vhffs-backend/conf/vhffs.conf.dist.in 2010-03-19 07:02:20 UTC (rev 1568)
+++ trunk/vhffs-backend/conf/vhffs.conf.dist.in 2010-03-19 23:26:29 UTC (rev 1569)
@@ -375,6 +375,22 @@
url_doc = http://help.myhoster.net/git
</git>
+ # Configuration for mercurial
+ <mercurial>
+ # Use this module or not
+ activate = no
+
+ # URL to the gitweb
+ # the url scheme is mercurialweb_url/mercurial_$group_$mercurialname/ , change the code or modify the software used
+ mercurialweb_url = "http://mercurialweb.hoster"
+
+ # From: of emails sent by mercurial commit notifier
+ notify_from = mercurial@xxxxxxxxx
+
+ # URL to the documentation (optional)
+ url_doc = http://help.myhoster.net/mercurial
+ </mercurial>
+
# Configuration for mail service
<mail>
# Use this module or not
Modified: trunk/vhffs-backend/src/pgsql/initdb.sql.in
===================================================================
--- trunk/vhffs-backend/src/pgsql/initdb.sql.in 2010-03-19 07:02:20 UTC (rev 1568)
+++ trunk/vhffs-backend/src/pgsql/initdb.sql.in 2010-03-19 23:26:29 UTC (rev 1569)
@@ -408,6 +408,22 @@
CONSTRAINT vhffs_git_pkey PRIMARY KEY( git_id )
) WITH OIDS;
+-- Mercurial repositories
+
+CREATE TABLE vhffs_mercurial
+(
+ mercurial_id SERIAL,
+-- Name of the repo
+ reponame varchar NOT NULL,
+-- Is the repo public or not
+ public int4 NOT NULL,
+-- Mailing list to which send commit mails
+ ml_name varchar,
+-- Object representing this Git repository
+ object_id int4 NOT NULL,
+ CONSTRAINT vhffs_mercurial_pkey PRIMARY KEY( mercurial_id )
+) WITH OIDS;
+
-- Cron tasks
CREATE TABLE vhffs_cron
@@ -523,6 +539,7 @@
ALTER TABLE vhffs_repository ADD CONSTRAINT vhffs_repository_unique_name UNIQUE (name);
ALTER TABLE vhffs_svn ADD CONSTRAINT vhffs_svn_unique_reponame UNIQUE (reponame);
ALTER TABLE vhffs_git ADD CONSTRAINT vhffs_git_unique_reponame UNIQUE (reponame);
+ALTER TABLE vhffs_mercurial ADD CONSTRAINT vhffs_mercurial_unique_reponame UNIQUE (reponame);
ALTER TABLE vhffs_dns ADD CONSTRAINT vhffs_dns_unique_domain UNIQUE (domain);
ALTER TABLE vhffs_ml ADD CONSTRAINT vhffs_ml_unique_address UNIQUE (local_part, domain);
ALTER TABLE vhffs_ml_subscribers ADD CONSTRAINT vhffs_ml_subscribers_member_list UNIQUE (ml_id, member);
@@ -546,6 +563,8 @@
CREATE INDEX idx_vhffs_svn_public ON vhffs_svn(public);
-- vhffs_git.public may be used in where clause to display public git
CREATE INDEX idx_vhffs_git_public ON vhffs_git(public);
+-- vhffs_mercurial.public may be used in where clause to display public mercurial
+CREATE INDEX idx_vhffs_mercurial_public ON vhffs_mercurial(public);
-- vhffs_ml.open_archive may be used in where clause to select on public ml
CREATE INDEX idx_vhffs_ml_open_archive ON vhffs_ml(open_archive);
-- vhffs_object.owner_uid and owner_gid is used a lot in where clauses
@@ -575,6 +594,7 @@
CREATE INDEX idx_vhffs_repository_object_id ON vhffs_repository(object_id);
CREATE INDEX idx_vhffs_svn_object_id ON vhffs_svn(object_id);
CREATE INDEX idx_vhffs_git_object_id ON vhffs_git(object_id);
+CREATE INDEX idx_vhffs_mercurial_object_id ON vhffs_mercurial(object_id);
-- add index on dates, it is used to search old object, ...
CREATE INDEX idx_vhffs_object_date_creation ON vhffs_object(date_creation);
CREATE INDEX idx_vhffs_history_date ON vhffs_history(date);
@@ -633,6 +653,8 @@
ALTER TABLE vhffs_git ADD CONSTRAINT fk_vhffs_git_vhffs_object FOREIGN KEY (object_id) REFERENCES vhffs_object(object_id) ON DELETE CASCADE;
+ALTER TABLE vhffs_mercurial ADD CONSTRAINT fk_vhffs_mercurial_vhffs_object FOREIGN KEY (object_id) REFERENCES vhffs_object(object_id) ON DELETE CASCADE;
+
ALTER TABLE vhffs_users ADD CONSTRAINT fk_vhffs_users_vhffs_object FOREIGN KEY (object_id) REFERENCES vhffs_object (object_id) ON DELETE CASCADE;
ALTER TABLE vhffs_user_group ADD CONSTRAINT fk_vhffs_user_group_vhffs_users FOREIGN KEY (uid) REFERENCES vhffs_users (uid) ON DELETE CASCADE;
Modified: trunk/vhffs-panel/Makefile.am
===================================================================
--- trunk/vhffs-panel/Makefile.am 2010-03-19 07:02:20 UTC (rev 1568)
+++ trunk/vhffs-panel/Makefile.am 2010-03-19 23:26:29 UTC (rev 1569)
@@ -76,6 +76,9 @@
admin/git/index.pl \
admin/git/list.pl \
admin/git/search.pl \
+ admin/mercurial/index.pl \
+ admin/mercurial/list.pl \
+ admin/mercurial/search.pl \
admin/user/index.pl \
admin/user/list.pl \
admin/user/search.pl \
@@ -139,6 +142,10 @@
git/delete.pl \
git/index.pl \
git/prefs.pl \
+ mercurial/create.pl \
+ mercurial/delete.pl \
+ mercurial/index.pl \
+ mercurial/prefs.pl \
user/delete.pl \
user/prefs.pl \
web/create.pl \
Added: trunk/vhffs-panel/admin/mercurial/index.pl
===================================================================
--- trunk/vhffs-panel/admin/mercurial/index.pl (rev 0)
+++ trunk/vhffs-panel/admin/mercurial/index.pl 2010-03-19 23:26:29 UTC (rev 1569)
@@ -0,0 +1,61 @@
+#!%PERL% -w
+# 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 utf8;
+use POSIX qw(locale_h);
+use HTML::Template;
+use locale;
+use Locale::gettext;
+use strict;
+
+
+use lib '%VHFFS_LIB_DIR%';
+use Vhffs::Panel::Main;
+use Vhffs::Panel::Admin;
+
+my $panel = new Vhffs::Panel::Main();
+exit 0 unless $panel;
+my $session = $panel->get_session;
+exit 0 unless $session;
+
+$panel->check_admin;
+
+my $templatedir = $panel->{templatedir};
+
+my $template = new HTML::Template(filename => $templatedir.'/panel/admin/index.tmpl');
+
+$panel->set_title( gettext('Mercurial repositories\' administration') );
+
+$template->param( CATEGORIES => [ Vhffs::Panel::Admin::get_mercurial_category ] );
+
+$panel->build( $template );
+$panel->display;
Property changes on: trunk/vhffs-panel/admin/mercurial/index.pl
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/vhffs-panel/admin/mercurial/list.pl
===================================================================
--- trunk/vhffs-panel/admin/mercurial/list.pl (rev 0)
+++ trunk/vhffs-panel/admin/mercurial/list.pl 2010-03-19 23:26:29 UTC (rev 1569)
@@ -0,0 +1,90 @@
+#!%PERL% -w
+# 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 HTML::Template;
+use Locale::gettext;
+
+use lib '%VHFFS_LIB_DIR%';
+use Vhffs::Panel::Main;
+use Vhffs::Panel::Mercurial;
+
+my $panel = new Vhffs::Panel::Main();
+exit 0 unless $panel;
+my $session = $panel->get_session;
+exit 0 unless $session;
+
+my $vhffs = $panel->{'vhffs'};
+my $user = $panel->{'user'};
+my $cgi = $panel->{'cgi'};
+my $templatedir = $panel->{'templatedir'};
+my $template;
+
+if( ($user->is_moderator != 1 ) && ( $user->is_admin != 1 ) )
+{
+ $template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
+ $template->param( MESSAGE => gettext('You are not allowed to see it') );
+}
+else
+{
+ $template = new HTML::Template( filename => $templatedir.'/panel/admin/misc/list.tmpl' );
+ my $name = $cgi->param('NAME');
+
+ if( defined( $name ) )
+ {
+ $template->param( TITLE => gettext('Search result for mercurial repository').': '.$name );
+ }
+ else
+ {
+ $template->param( TITLE => gettext('All mercurial repositories lists') );
+ }
+
+ $template->param(TEXT_TITLE1 => gettext('Mercurial root'));
+ $template->param(TEXT_TITLE2 => gettext('Group'));
+ $template->param(TEXT_TITLE3 => gettext('State'));
+
+ my $repos = Vhffs::Panel::Mercurial::search( $vhffs, $name );
+ if( defined $repos )
+ {
+ my $subtemplate = new HTML::Template( filename => $templatedir.'/panel/admin/mercurial/part.tmpl', global_vars => 1 );
+ if( $user->is_admin == 1 ) {
+ $subtemplate->param( ACTION => gettext('Modify') );
+ } else {
+ $subtemplate->param( ACTION => gettext('Show') );
+ }
+ $subtemplate->param( MERCURIALREPOS => $repos);
+ $template->param( LIST => $subtemplate->output );
+ }
+}
+
+$panel->build( $template );
+$panel->display;
Property changes on: trunk/vhffs-panel/admin/mercurial/list.pl
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/vhffs-panel/admin/mercurial/search.pl
===================================================================
--- trunk/vhffs-panel/admin/mercurial/search.pl (rev 0)
+++ trunk/vhffs-panel/admin/mercurial/search.pl 2010-03-19 23:26:29 UTC (rev 1569)
@@ -0,0 +1,84 @@
+#!%PERL% -w
+# 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 utf8;
+use POSIX qw(locale_h);
+use HTML::Template;
+use locale;
+use Locale::gettext;
+use CGI;
+use CGI::Session;
+use strict;
+
+
+use lib '%VHFFS_LIB_DIR%';
+use Vhffs::User;
+use Vhffs::Group;
+use Vhffs::Main;
+use Vhffs::Panel::Main;
+use Vhffs::Panel::Menu;
+use Vhffs::Stats;
+use Vhffs::Constants;
+
+my $panel = new Vhffs::Panel::Main();
+exit 0 unless $panel;
+my $session = $panel->get_session;
+exit 0 unless $session;
+
+my $vhffs = $panel->{'vhffs'};
+my $maintemplate = $panel->{'template'};
+my $user = $panel->{'user'};
+my $cgi = $panel->{'cgi'};
+my $servername = $cgi->param("name");
+my $template;
+
+
+my $templatesdir = $vhffs->get_config->get_templatedir;
+
+if( ($user->is_moderator != 1 ) && ( $user->is_admin != 1 ) )
+{
+
+ $template = new HTML::Template( filename => $templatesdir."/panel/misc/simplemsg.tmpl" );
+ my $message = gettext( "You are not allowed to see it");
+ $template->param( MESSAGE => $message );
+}
+else
+{
+ $template = new HTML::Template( filename => $templatesdir."/panel/admin/mercurial/search.tmpl" );
+
+ $template->param( TITLE => gettext("Search for a Mercurial repository") );
+
+}
+
+$panel->build( $template );
+$panel->display;
+
Property changes on: trunk/vhffs-panel/admin/mercurial/search.pl
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/vhffs-panel/mercurial/create.pl
===================================================================
--- trunk/vhffs-panel/mercurial/create.pl (rev 0)
+++ trunk/vhffs-panel/mercurial/create.pl 2010-03-19 23:26:29 UTC (rev 1569)
@@ -0,0 +1,107 @@
+#!%PERL% -w
+# 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 POSIX qw(locale_h);
+use HTML::Template;
+use locale;
+use Locale::gettext;
+use CGI;
+use CGI::Session;
+use Encode;
+
+use lib '%VHFFS_LIB_DIR%';
+use Vhffs::User;
+use Vhffs::Group;
+use Vhffs::Main;
+use Vhffs::Panel::Main;
+use Vhffs::Panel::Menu;
+use Vhffs::Panel::Group;
+
+my $panel = new Vhffs::Panel::Main();
+exit 0 unless $panel;
+my $session = $panel->get_session;
+exit 0 unless $session;
+
+my $vhffs = $panel->{vhffs};
+my $templatedir = $panel->{templatedir};
+my $cgi = $panel->{cgi};
+my $user = $panel->{user};
+my $group = Vhffs::Group::get_by_groupname( $vhffs , $cgi->param('group') );
+
+unless( defined $group && $user->can_modify( $group ) ) {
+ my $template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
+ $template->param( MESSAGE => gettext( 'You\'re not allowed to do this (ACL rights)' ) );
+
+ $panel->build( $template );
+ $panel->display;
+}
+else {
+ my $submitted = $cgi->param('mercurial_submit');
+ my $reponame = '';
+ my $description = '';
+
+ if( $submitted ) {
+ $reponame = $cgi->param('reponame');
+ my $fullreponame = $group->get_groupname.'/'.$reponame;
+ $description = Encode::decode_utf8( $cgi->param('description') );
+ unless( defined $reponame && defined $description ) {
+ $panel->add_error( gettext('CGI Error !') );
+ } elsif( !Vhffs::Services::Mercurial::check_name($fullreponame) ) {
+ $panel->add_error( gettext('Invalid reponame. It must contain between 3 and 64 characters, only lowercase letters and numbers') );
+ } elsif( $description =~ /^\s*$/) {
+ $panel->add_error( gettext('You must enter a description') );
+ } elsif( defined Vhffs::Panel::Mercurial::create_mercurial( $vhffs, $fullreponame, $description, $user, $group ) ) {
+ my $url = '/group/view.pl?group='.$group->get_groupname.'&msg='.gettext('The Mercurial object was successfully created !');
+ $panel->redirect($url);
+ } else {
+ $panel->add_error( gettext('An error occured while creating the mercurial repository') );
+ }
+ }
+
+ if( !$submitted || $panel->has_errors ) {
+ my $template = new HTML::Template( filename => $templatedir.'/panel/mercurial/create.tmpl' );
+
+ $panel->set_title( gettext('Create a mercurial Repository') );
+ $template->param( REPOSITORY_NAME => gettext('Repository Name') );
+ $template->param( REPOSITORY_VALUE => $reponame );
+ $template->param( GROUP_NAME => gettext('Group owning this mercurial repository') );
+
+ $template->param( GROUP => $group->get_groupname );
+ $template->param( SEND => gettext('Send') );
+ $template->param( DESCRIPTION => gettext('Description') );
+ $template->param( DESCRIPTION_VALUE => $description );
+
+ $panel->build( $template );
+ $panel->display;
+ }
+}
Property changes on: trunk/vhffs-panel/mercurial/create.pl
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/vhffs-panel/mercurial/delete.pl
===================================================================
--- trunk/vhffs-panel/mercurial/delete.pl (rev 0)
+++ trunk/vhffs-panel/mercurial/delete.pl 2010-03-19 23:26:29 UTC (rev 1569)
@@ -0,0 +1,108 @@
+#!%PERL% -w
+# 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 utf8;
+use POSIX qw(locale_h);
+use HTML::Template;
+use locale;
+use Locale::gettext;
+use CGI;
+use CGI::Session;
+use strict;
+
+use lib '%VHFFS_LIB_DIR%';
+use Vhffs::User;
+use Vhffs::Main;
+use Vhffs::Group;
+use Vhffs::Panel::Main;
+use Vhffs::Panel::Menu;
+use Vhffs::Panel::Group;
+
+my $panel = new Vhffs::Panel::Main();
+exit 0 unless $panel;
+my $session = $panel->get_session;
+exit 0 unless $session;
+
+my $vhffs = $panel->{'vhffs'};
+my $maintemplate = $panel->{'template'};
+my $user = $panel->{'user'};
+my $cgi = $panel->{'cgi'};
+my $message;
+my $owner = $cgi->param("PROJECT_OWNER");
+
+my $repo = $cgi->param( "name" );
+my $sure = $cgi->param( "DELETE" );
+
+my $mercurial = Vhffs::Services::Mercurial::get_by_reponame( $vhffs , $repo );
+
+my $templatedir = $vhffs->get_config->get_templatedir;
+
+if( ( ! defined $repo ) || ( ! defined $sure ) )
+{
+ $message = gettext("CGI Error !");
+}
+elsif( ! defined $mercurial )
+{
+ $message = gettext( "Cannot retrieve informations about this repository" );
+}
+elsif( !$user->can_delete( $mercurial ) )
+{
+ $message = gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' );
+}
+elsif( $mercurial->get_status != Vhffs::Constants::ACTIVATED )
+{
+ $message = gettext( "This object is not functionnal yet. Please wait creation or moderation.");
+}
+elsif( $sure == 0 )
+{
+ $message = gettext( "This mercurial repository will NOT be deleted" );
+}
+else
+{
+ $mercurial->set_status( Vhffs::Constants::TO_DELETE );
+
+ # Commit all the changes for the current user
+ if( $mercurial->commit < 0 )
+ {
+ $message = gettext("An error occured while deleting the mercurial repository");
+ }
+ else
+ {
+ $message = gettext("This repository will be deleted");
+ }
+}
+
+my $template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
+$template->param( MESSAGE => $message );
+
+$panel->build( $template );
+$panel->display;
Property changes on: trunk/vhffs-panel/mercurial/delete.pl
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/vhffs-panel/mercurial/index.pl
===================================================================
--- trunk/vhffs-panel/mercurial/index.pl (rev 0)
+++ trunk/vhffs-panel/mercurial/index.pl 2010-03-19 23:26:29 UTC (rev 1569)
@@ -0,0 +1,72 @@
+#!%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 utf8;
+use POSIX qw(locale_h);
+use HTML::Template;
+use locale;
+use Locale::gettext;
+use strict;
+
+use lib '%VHFFS_LIB_DIR%';
+use Vhffs::Panel::Main;
+use Vhffs::Panel::Mercurial;
+
+my $panel = new Vhffs::Panel::Main();
+exit 0 unless $panel;
+my $session = $panel->get_session;
+exit 0 unless $session;
+
+my $vhffs = $panel->{vhffs};
+my $cgi = $panel->{'cgi'};
+my $group = Vhffs::Group::get_by_groupname( $vhffs , $cgi->param('group') );
+
+if( ! defined($group) ) {
+ $panel->set_title( gettext('Error') );
+ $panel->add_error( gettext('You have to select a group first') );
+ $panel->build;
+ $panel->display;
+} else {
+ # Group is in session => access is granted for user and group is activated
+ # no need to check
+ $panel->set_title( sprintf(gettext('Mercurial repositories for %s'), $group->get_groupname) );
+ my $mercurial = Vhffs::Panel::Mercurial::getall_per_group( $vhffs, $group->get_gid );
+ if($mercurial < 0) {
+ $panel->add_error( gettext('Unable to get Mercurial repositories') );
+ $panel->build;
+ $panel->display;
+ } else {
+ $panel->build( $panel->create_service_index('mercurial', $mercurial) );
+ $panel->display;
+ }
+}
+
Property changes on: trunk/vhffs-panel/mercurial/index.pl
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/vhffs-panel/mercurial/prefs.pl
===================================================================
--- trunk/vhffs-panel/mercurial/prefs.pl (rev 0)
+++ trunk/vhffs-panel/mercurial/prefs.pl 2010-03-19 23:26:29 UTC (rev 1569)
@@ -0,0 +1,178 @@
+#!%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 utf8;
+use POSIX qw(locale_h);
+use HTML::Template;
+use locale;
+use Locale::gettext;
+use CGI;
+use CGI::Session;
+use strict;
+
+use lib '%VHFFS_LIB_DIR%';
+use Vhffs::User;
+use Vhffs::Main;
+use Vhffs::Panel::Main;
+use Vhffs::Panel::Menu;
+use Vhffs::Panel::Object;
+use Vhffs::Panel::Template;
+
+my $panel = new Vhffs::Panel::Main();
+exit 0 unless $panel;
+my $session = $panel->get_session;
+exit 0 unless $session;
+
+my $vhffs = $panel->{'vhffs'};
+my $user = $panel->{'user'};
+my $cgi = $panel->{'cgi'};
+my $templatedir = $panel->{'templatedir'};
+
+my $repo_name = $cgi->param('name');
+
+my $template;
+
+my $mercurial = Vhffs::Services::Mercurial::get_by_reponame( $vhffs , $repo_name );
+my $group = Vhffs::Group::get_by_gid( $vhffs , $mercurial->{'owner_gid'} );
+
+unless( defined $repo_name )
+{
+ $template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
+ $template->param( MESSAGE => gettext( 'CGI Error !' ) );
+}
+elsif( !defined $mercurial )
+{
+ $template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
+ $template->param( MESSAGE => gettext( 'Cannot get informations on this object' ) );
+}
+elsif( !$user->can_view( $mercurial ) )
+{
+ $template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
+ $template->param( MESSAGE => gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' ) );
+}
+else
+{
+ if(defined $cgi->param('save_prefs_submit') ) {
+ if(save_prefs()) {
+ exit;
+ }
+ }
+
+ $template = new Vhffs::Panel::Template( filename => $templatedir."/panel/mercurial/prefs.tmpl" );
+
+ $panel->set_title( gettext("Admin Mercurial Repository") );
+
+ $template->param( TEXT_REPONAME => $mercurial->get_reponame );
+ $template->param( TITLE_PUBLIC => gettext("Public") );
+ $template->param( TEXT_PUBLIC => gettext("Is this a public repository ?") );
+ $template->param( PUBLIC_YES => gettext("Yes") );
+ $template->param( PUBLIC_NO => gettext("No") );
+ $template->param( TEXT_SEND => gettext("Modify") );
+ $template->param( TEXT_DELETE_CVS => gettext("Delete this repository") );
+ $template->param( TEXT_BEFORE_DELETE => gettext("This action is non-reversible. This mercurial repository will be DESTROYED.") );
+ $template->param( ASK_DELETE_CVS => gettext("Are you SURE you want DELETE this mercurial repository?") );
+ $template->param( YES => gettext("Yes I'm sure of what I do") );
+ $template->param( NO => gettext("No, I'm not sure, I prefer to keep this project.") );
+ $template->param( TEXT_DELETE => gettext("Delete") );
+
+ $template->param( VALUE_OID => $mercurial->get_oid );
+ $template->param( TEXT_ACL_ADMIN => gettext('Admin Rights on this object (ACL)') );
+ $template->param( EXPLAIN_ADMIN_ACL => gettext('You can Manage rights on this service for each user in the VHFFS database. Please read help before manage it.') );
+ $template->param( ADMIN_ACL => gettext('Ok, go to ACL admin') );
+
+ $template->param( TITLE_OPT => gettext('Options') );
+ $template->param( TEXT_OPT_ML => gettext('Notify changes on mailing-list :'));
+ $template->param( TEXT_OPT_ML_REMINDER => sprintf( gettext('Don\'t forget to subscribe %s to your mailing list if you are filtering posts') , $vhffs->get_config->get_service('mercurial')->{notify_from} ) );
+ $template->param( TEXT_ML_NAME => $mercurial->{ml_name} );
+
+ if( $mercurial->is_public == 1 )
+ {
+ $template->param( YES_SELECTED => "selected" );
+ }
+ else
+ {
+ $template->param( NO_SELECTED => "selected" );
+ }
+
+ my $adminpart = Vhffs::Panel::Object::admin_part( $panel, $mercurial );
+ $template->param( ADMIN_PART => $adminpart->output ) if( defined $adminpart );
+}
+
+$panel->build( $template );
+$panel->display;
+
+sub save_prefs {
+ my $public = $cgi->param('public');
+ my $ml_name = $cgi->param('ml_name');
+
+ if(!$user->can_modify($mercurial)) {
+ $panel->add_error( gettext('You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights') );
+ return 0;
+ }
+
+ if(!defined($public) || !defined($ml_name)) {
+ $panel->add_error( gettext('CGI error !') );
+ return 0;
+ }
+
+ if($public != $mercurial->is_public) {
+ if($public == 1) {
+ $mercurial->set_public();
+ } else {
+ $mercurial->set_private();
+ }
+ $mercurial->set_status(Vhffs::Constants::WAITING_FOR_MODIFICATION);
+ }
+
+ if(($ml_name =~ /^\s*$/ || Vhffs::Functions::valid_mail($ml_name))) {
+ if($ml_name ne $mercurial->get_ml_name) {
+ $mercurial->set_ml_name($ml_name);
+ $mercurial->set_status( Vhffs::Constants::WAITING_FOR_MODIFICATION );
+ }
+ } else {
+ $panel->add_error( gettext('Invalid mailing list address') );
+ return 0;
+ }
+
+ if($mercurial->get_status == Vhffs::Constants::WAITING_FOR_MODIFICATION) {
+ if($mercurial->commit < 0) {
+ $panel->add_error( gettext('Unable to apply modifications') );
+ return 0;
+ } else {
+ my $url = '/group/view.pl?group='.$group->get_groupname.'&msg='.gettext('Modifications applied. Please wait while your repository is being updated');
+ $panel->redirect($url);
+ return 1;
+ }
+ }
+
+ return 0;
+}
Property changes on: trunk/vhffs-panel/mercurial/prefs.pl
___________________________________________________________________
Added: svn:executable
+ *
Modified: trunk/vhffs-panel/templates/Makefile.am
===================================================================
--- trunk/vhffs-panel/templates/Makefile.am 2010-03-19 07:02:20 UTC (rev 1568)
+++ trunk/vhffs-panel/templates/Makefile.am 2010-03-19 23:26:29 UTC (rev 1569)
@@ -48,6 +48,8 @@
admin/tag/request/list.tmpl \
admin/git/part.tmpl \
admin/git/search.tmpl \
+ admin/mercurial/part.tmpl \
+ admin/mercurial/search.tmpl \
admin/user/part.tmpl \
admin/user/search.tmpl \
admin/web/part.tmpl \
@@ -118,6 +120,9 @@
git/create.tmpl \
git/prefs.tmpl \
git/user_part.tmpl \
+ mercurial/create.tmpl \
+ mercurial/prefs.tmpl \
+ mercurial/user_part.tmpl \
user/admin.tmpl \
user/create_complete.tmpl \
user/create.tmpl \
Added: trunk/vhffs-panel/templates/admin/mercurial/part.tmpl
===================================================================
--- trunk/vhffs-panel/templates/admin/mercurial/part.tmpl (rev 0)
+++ trunk/vhffs-panel/templates/admin/mercurial/part.tmpl 2010-03-19 23:26:29 UTC (rev 1569)
@@ -0,0 +1,16 @@
+<TMPL_LOOP NAME="MERCURIALREPOS">
+<tr>
+ <td>
+ <TMPL_VAR ESCAPE=1 NAME="MERCURIALROOT">
+ </td>
+ <td>
+ <TMPL_VAR ESCAPE=1 NAME="GROUPNAME">
+ </td>
+ <td>
+ <TMPL_VAR ESCAPE=1 NAME="STATE">
+ </td>
+ <td>
+ <a href="/mercurial/prefs.pl?admin_menu=1&name=<TMPL_VAR ESCAPE=1 NAME="MERCURIALROOT">"><TMPL_VAR ESCAPE=1 NAME="ACTION"></a>
+ </td>
+</tr>
+</TMPL_LOOP>
Added: trunk/vhffs-panel/templates/admin/mercurial/search.tmpl
===================================================================
--- trunk/vhffs-panel/templates/admin/mercurial/search.tmpl (rev 0)
+++ trunk/vhffs-panel/templates/admin/mercurial/search.tmpl 2010-03-19 23:26:29 UTC (rev 1569)
@@ -0,0 +1,4 @@
+ <h1><TMPL_VAR ESCAPE=1 NAME="TITLE"></h1>
+ <form method="post" action="list.pl" accept-charset="utf-8">
+ <input type="text" name="NAME" value=""/>
+ </form>
Added: trunk/vhffs-panel/templates/mercurial/create.tmpl
===================================================================
--- trunk/vhffs-panel/templates/mercurial/create.tmpl (rev 0)
+++ trunk/vhffs-panel/templates/mercurial/create.tmpl 2010-03-19 23:26:29 UTC (rev 1569)
@@ -0,0 +1,24 @@
+<form method="post" action="#" accept-charset="utf-8">
+ <p>
+ <label>
+ <TMPL_VAR ESCAPE=1 NAME="GROUP_NAME">:
+ </label>
+ <TMPL_VAR ESCAPE=1 NAME="GROUP">
+ </p>
+ <p>
+ <label for="reponame">
+ <TMPL_VAR ESCAPE=1 NAME="REPOSITORY_NAME">:
+ </label>
+ <TMPL_VAR ESCAPE=1 NAME="GROUP">/<input type="text" name="reponame" id="reponame" value="<TMPL_VAR ESCAPE=1 NAME="REPOSITORY_VALUE">"/>
+ </p>
+ <p>
+ <label for="PROJECT_USAGE">
+ <TMPL_VAR ESCAPE=1 NAME="description">:
+ </label>
+ <textarea name="description" id="description" cols="45" rows="7"><TMPL_VAR ESCAPE=1 NAME="DESCRIPTION_VALUE"></textarea>
+ </p>
+ <p class="button" id="buttonSend">
+ <input type="hidden" name="group" value="<TMPL_VAR ESCAPE=1 NAME="GROUP">" />
+ <input type="submit" value="<TMPL_VAR ESCAPE=1 NAME="SEND">" name="mercurial_submit"/>
+ </p>
+</form>
Added: trunk/vhffs-panel/templates/mercurial/prefs.tmpl
===================================================================
--- trunk/vhffs-panel/templates/mercurial/prefs.tmpl (rev 0)
+++ trunk/vhffs-panel/templates/mercurial/prefs.tmpl 2010-03-19 23:26:29 UTC (rev 1569)
@@ -0,0 +1,70 @@
+<h2><TMPL_VAR ESCAPE=1 NAME="TITLE_PUBLIC"></h2>
+
+
+<form method="post" action="/mercurial/prefs.pl" accept-charset="utf-8">
+ <p>
+ <label for="public">
+ <TMPL_VAR ESCAPE=1 NAME="TEXT_PUBLIC"> :
+ </label>
+ <select name="public" id="public">
+ <option value="1" <TMPL_VAR ESCAPE=1 NAME="YES_SELECTED">><TMPL_VAR ESCAPE=1 NAME="PUBLIC_YES"></option>
+ <option value="0" <TMPL_VAR ESCAPE=1 NAME="NO_SELECTED">><TMPL_VAR ESCAPE=1 NAME="PUBLIC_NO"></option>
+ </select>
+ </p>
+<h2><TMPL_VAR ESCAPE=1 NAME="TITLE_OPT"></h2>
+ <p>
+ <label for="ml_name"><TMPL_VAR ESCAPE=1 NAME="TEXT_OPT_ML"></label>
+ <input type="text" name="ml_name" id="ml_name" value="<TMPL_VAR ESCAPE=1 NAME="TEXT_ML_NAME">" />
+ <br/>
+ <TMPL_VAR ESCAPE=1 NAME="TEXT_OPT_ML_REMINDER">
+ </p>
+ <p class="button">
+ <input type="hidden" name="name" value="<TMPL_VAR ESCAPE=1 NAME="TEXT_REPONAME">" />
+ <input type="submit" value="<TMPL_VAR ESCAPE=1 NAME="TEXT_SEND">" name="save_prefs_submit"/>
+ </p>
+</form>
+
+
+<h2><TMPL_VAR ESCAPE=1 NAME="TEXT_ACL_ADMIN"></h2>
+
+<form method="post" action="../acl/view.pl" accept-charset="utf-8">
+ <p><TMPL_VAR ESCAPE=1 NAME="EXPLAIN_ADMIN_ACL"></p>
+
+ <input type="hidden" name="target_oid" value="<TMPL_VAR ESCAPE=1 NAME="VALUE_OID">" />
+ <p class="button" id="buttonAclAdmin">
+ <input type="submit" value="<TMPL_VAR ESCAPE=1 NAME="ADMIN_ACL">" />
+ </p>
+</form>
+
+
+<h2><TMPL_VAR ESCAPE=1 NAME="TEXT_DELETE_CVS"></h2>
+
+<form method="post" action="delete.pl" accept-charset="utf-8">
+ <fieldset class="delete">
+ <legend>
+ <TMPL_VAR ESCAPE=1 NAME="ASK_DELETE_CVS">:
+ </legend>
+
+ <p class="warning"><TMPL_VAR ESCAPE=1 NAME="TEXT_BEFORE_DELETE"></p>
+ <p>
+ <input type="radio" name="DELETE" id="DELETE_NO" value="0" checked="checked" />
+ <label for="DELETE_NO">
+ <TMPL_VAR ESCAPE=1 NAME="NO">
+ </label>
+ </p>
+ <p>
+ <input type="radio" name="DELETE" id="DELETE_YES" value="1" />
+ <label for="DELETE_YES">
+ <TMPL_VAR ESCAPE=1 NAME="YES">
+ </label>
+ </p>
+ </fieldset>
+
+ <p class="button" id="buttonDelete">
+ <input type="hidden" name="name" value="<TMPL_VAR ESCAPE=1 NAME="TEXT_REPONAME">" />
+ <input type="submit" value="<TMPL_VAR ESCAPE=1 NAME="TEXT_DELETE">" />
+ </p>
+
+</form>
+
+<TMPL_VAR ESCAPE=0 NAME="ADMIN_PART">
Added: trunk/vhffs-panel/templates/mercurial/user_part.tmpl
===================================================================
--- trunk/vhffs-panel/templates/mercurial/user_part.tmpl (rev 0)
+++ trunk/vhffs-panel/templates/mercurial/user_part.tmpl 2010-03-19 23:26:29 UTC (rev 1569)
@@ -0,0 +1,21 @@
+
+<tr>
+ <td><TMPL_VAR ESCAPE=1 NAME="VALUE_USERNAME"></td>
+ <td>
+ <form method="post" action="mercurial_chpwd.pl" accept-charset="utf-8">
+ <input type="text" name="PASSWORD" value="" />
+ <input type="hidden" name="REPO" value="<TMPL_VAR ESCAPE=1 NAME="VALUE_REPONAME">" />
+ <input type="hidden" name="USERNAME" value="<TMPL_VAR ESCAPE=1 NAME="VALUE_USERNAME">" />
+ <input type="submit" value="<TMPL_VAR ESCAPE=1 NAME="TEXT_BUTTON_CHANGEPWD">" />
+ </form>
+ </td>
+ <td>
+ <form method="post" action="mercurial_deleteuser.pl" accept-charset="utf-8">
+ <input type="hidden" name="REPO" value="<TMPL_VAR ESCAPE=1 NAME="VALUE_REPONAME">" />
+ <input type="hidden" name="USERNAME" value="<TMPL_VAR ESCAPE=1 NAME="VALUE_USERNAME">" />
+ <input type="submit" value="<TMPL_VAR ESCAPE=1 NAME="TEXT_BUTTON_DELETE">" />
+ </form>
+ </td>
+</tr>
+
+
Modified: trunk/vhffs-robots/Makefile.am
===================================================================
--- trunk/vhffs-robots/Makefile.am 2010-03-19 07:02:20 UTC (rev 1568)
+++ trunk/vhffs-robots/Makefile.am 2010-03-19 23:26:29 UTC (rev 1569)
@@ -61,6 +61,9 @@
src/git_create.pl \
src/git_delete.pl \
src/git_public.pl \
+ src/mercurial_create.pl \
+ src/mercurial_delete.pl \
+ src/mercurial_public.pl \
src/user_create.pl \
src/user_delete.pl \
src/user_group.pl \
Added: trunk/vhffs-robots/src/mercurial_create.pl
===================================================================
--- trunk/vhffs-robots/src/mercurial_create.pl (rev 0)
+++ trunk/vhffs-robots/src/mercurial_create.pl 2010-03-19 23:26:29 UTC (rev 1569)
@@ -0,0 +1,59 @@
+#!%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::Mercurial;
+use Vhffs::Services::Mercurial;
+use Vhffs::Constants;
+
+
+my $vhffs = init Vhffs::Main;
+
+Vhffs::Robots::lock( $vhffs , 'mercurial' );
+
+my $repos = Vhffs::Services::Mercurial::getall( $vhffs , Vhffs::Constants::WAITING_FOR_CREATION);
+foreach my $mercurial ( @{$repos} )
+{
+ if( Vhffs::Robots::Mercurial::create_repo( $mercurial ) != 0 ) {
+ Vhffs::Robots::vhffs_log( sprintf( 'Cannot create Mercurial %s' , $mercurial->get_reponame ), $vhffs);
+ } else {
+ Vhffs::Robots::vhffs_log( sprintf( 'Created Mercurial %s' , $mercurial->get_reponame ), $vhffs);
+ }
+}
+
+
+Vhffs::Robots::unlock( $vhffs , 'mercurial' );
+exit 0;
Property changes on: trunk/vhffs-robots/src/mercurial_create.pl
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/vhffs-robots/src/mercurial_delete.pl
===================================================================
--- trunk/vhffs-robots/src/mercurial_delete.pl (rev 0)
+++ trunk/vhffs-robots/src/mercurial_delete.pl 2010-03-19 23:26:29 UTC (rev 1569)
@@ -0,0 +1,64 @@
+#!%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::Mercurial;
+use Vhffs::Services::Mercurial;
+use Vhffs::Constants;
+
+
+my $vhffs = init Vhffs::Main;
+
+Vhffs::Robots::lock( $vhffs , 'mercurial' );
+
+my $repos = Vhffs::Services::Mercurial::getall( $vhffs , Vhffs::Constants::TO_DELETE );
+foreach my $mercurial ( @{$repos} )
+{
+ if( Vhffs::Robots::Mercurial::delete_repo( $mercurial ) != 0 ) {
+ Vhffs::Robots::vhffs_log( sprintf( 'Cannot delete files from Mercurial repository %s' , $mercurial->get_reponame ), $vhffs);
+ } else {
+ Vhffs::Robots::vhffs_log( sprintf( 'Delete files from Mercurial repository %s' , $mercurial->get_reponame ), $vhffs);
+ }
+
+ if( $mercurial->delete < 0 ) {
+ Vhffs::Robots::vhffs_log( sprintf( 'Cannot delete Mercurial repository object %s' , $mercurial->get_reponame ), $vhffs);
+ } else {
+ Vhffs::Robots::vhffs_log( sprintf( 'Delete Mercurial repository object %s' , $mercurial->get_reponame ), $vhffs);
+ }
+}
+
+Vhffs::Robots::unlock( $vhffs , 'mercurial' );
+exit 0;
Property changes on: trunk/vhffs-robots/src/mercurial_delete.pl
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/vhffs-robots/src/mercurial_public.pl
===================================================================
--- trunk/vhffs-robots/src/mercurial_public.pl (rev 0)
+++ trunk/vhffs-robots/src/mercurial_public.pl 2010-03-19 23:26:29 UTC (rev 1569)
@@ -0,0 +1,71 @@
+#!%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::Mercurial;
+use Vhffs::Services::Mercurial;
+use Vhffs::Constants;
+
+
+my $vhffs = init Vhffs::Main;
+
+Vhffs::Robots::lock( $vhffs , 'mercurial' );
+
+my $repos = Vhffs::Services::Mercurial::getall( $vhffs , Vhffs::Constants::WAITING_FOR_MODIFICATION );
+foreach my $mercurial ( @{$repos} )
+{
+ if( $mercurial->is_public == 1 ) {
+ chmod 02775 , $mercurial->get_dir;
+ Vhffs::Robots::vhffs_log( sprintf( 'Mercurial status %s is now public' , $mercurial->get_dir ) , $vhffs);
+ } else {
+ chmod 02770 , $mercurial->get_dir;
+ Vhffs::Robots::vhffs_log( sprintf( 'Mercurial status %s is now private' , $mercurial->get_dir ) , $vhffs);
+ }
+
+ Vhffs::Robots::Mercurial::change_conf( $mercurial );
+ $mercurial->set_status( Vhffs::Constants::ACTIVATED );
+
+ if( $mercurial->commit < 0 ) {
+ $mercurial->add_history( 'Error while updating repository configuration' );
+ } else {
+ $mercurial->add_history( 'Successfully modify repository configuration' );
+ }
+}
+
+
+Vhffs::Robots::unlock( $vhffs , 'mercurial' );
+
+exit 0;
Property changes on: trunk/vhffs-robots/src/mercurial_public.pl
___________________________________________________________________
Added: svn:executable
+ *