[Rt-commit] r5898 - in commitbit: etc
clkao at bestpractical.com
clkao at bestpractical.com
Sun Sep 10 20:27:14 EDT 2006
Author: clkao
Date: Sun Sep 10 20:27:13 2006
New Revision: 5898
Modified:
commitbit/etc/config.yml
commitbit/lib/CommitBit/Model/Project.pm
commitbit/lib/CommitBit/Model/Repository.pm
Log:
it works!
Modified: commitbit/etc/config.yml
==============================================================================
--- commitbit/etc/config.yml (original)
+++ commitbit/etc/config.yml Sun Sep 10 20:27:13 2006
@@ -34,3 +34,5 @@
ServeStaticFiles: 1
StaticRoot: share/web/static
TemplateRoot: share/web/templates
+application:
+ repository_prefix: repos
Modified: commitbit/lib/CommitBit/Model/Project.pm
==============================================================================
--- commitbit/lib/CommitBit/Model/Project.pm (original)
+++ commitbit/lib/CommitBit/Model/Project.pm Sun Sep 10 20:27:13 2006
@@ -24,6 +24,18 @@
# Your model-specific methods go here.
+sub create {
+ my $self = shift;
+ my $args = { @_ };
+ my ($id, $msg) = $self->SUPER::create(%$args);
+
+ if ($id) {
+ $self->repository->add_project($self);
+ }
+ return ($id, $msg);
+
+}
+
sub members {
my $self = shift;
my $members = CommitBit::Model::UserCollection->new();
Modified: commitbit/lib/CommitBit/Model/Repository.pm
==============================================================================
--- commitbit/lib/CommitBit/Model/Repository.pm (original)
+++ commitbit/lib/CommitBit/Model/Repository.pm Sun Sep 10 20:27:13 2006
@@ -5,6 +5,7 @@
package CommitBit::Model::Repository;
use Jifty::DBI::Schema;
use File::Spec;
+use Cwd 'abs_path';
use CommitBit::Record schema {
@@ -45,9 +46,28 @@
$self->run_cmd("svn", @_);
}
+sub with_write_lock (&) {
+ my $sub = shift;
+ eval {
+ obtain_write_lock() || Carp::croak "Couldn't get write lock :(";
+ &$sub();
+ release_write_lock() || Carp::croak "Couldn't release write lock :(";
+ return 1;
+ };
+ return 0;
+}
+
+
sub create {
my $self = shift;
- my ($id, $msg) = $self->SUPER::create(@_);
+ my $args = { @_ };
+ my $prefix = abs_path( Jifty->config->app("repository_prefix") );
+
+ unless (length $args->{path}) {
+ $args->{path} = File::Spec->catdir($prefix, $args->{name});
+ }
+
+ my ($id, $msg) = $self->SUPER::create(%$args);
if ($id) {
# XXX: when failed rollback the create?
@@ -99,6 +119,7 @@
my $authz = {};
my $projects = CommitBit::Model::ProjectCollection->new();
+ $projects->unlimit;
with_write_lock {
@@ -144,17 +165,6 @@
}
-sub with_write_lock (&) {
- my $sub = shift;
- eval {
- obtain_write_lock() || Carp::croak "Couldn't get write lock :(";
- &$sub();
- release_write_lock() || Carp::croak "Couldn't release write lock :(";
- return 1;
- };
- return 0;
-}
-
sub obtain_write_lock {
return 1;
@@ -162,6 +172,8 @@
}
sub release_write_lock {
+
+ return 1;
}
More information about the Rt-commit
mailing list