[Bps-public-commit] r14340 - in Pushmi/trunk: . Pushmi-Admin/lib/Pushmi/Admin/Action Pushmi-Admin/lib/Pushmi/Admin/Model
alexmv at bestpractical.com
alexmv at bestpractical.com
Mon Jul 21 16:44:22 EDT 2008
Author: alexmv
Date: Mon Jul 21 16:44:19 2008
New Revision: 14340
Modified:
Pushmi/trunk/ (props changed)
Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/CheckURL.pm
Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/CreateReplica.pm
Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/Remirror.pm
Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/Sync.pm
Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Dispatcher.pm
Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Model/HttpRoot.pm
Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Model/Replica.pm
Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/View.pm
Log:
r34429 at kohr-ah: chmrr | 2008-07-21 16:44:11 -0400
* Perltidy
Modified: Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/CheckURL.pm
==============================================================================
--- Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/CheckURL.pm (original)
+++ Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/CheckURL.pm Mon Jul 21 16:44:19 2008
@@ -14,12 +14,12 @@
use Jifty::Action schema {
param name =>
- type is 'text',
- label is "Name";
+ type is 'text',
+ label is "Name";
param url =>
- type is 'text',
- label is "URL";
+ type is 'text',
+ label is "URL";
};
@@ -29,8 +29,9 @@
my $self = shift;
my ($url) = @_;
warn "Validating $url\n";
- return $self->validation_error( url => "We can only deal with http:// urls" )
- unless $url =~ m{^http://};
+ return $self->validation_error(
+ url => "We can only deal with http:// urls" )
+ unless $url =~ m{^http://};
$url =~ s{/+$}{};
@@ -53,18 +54,18 @@
);
};
my $err = $@;
- if ( not keys %{$props} or $err) {
+ if ( not keys %{$props} or $err ) {
$self->validation_error( url => "Read of $url failed\n" );
}
- $self->result->content(repository => $props);
- return $self->validation_ok( "url" );
+ $self->result->content( repository => $props );
+ return $self->validation_ok("url");
}
sub validate {
my $self = shift;
$self->SUPER::validate;
- if ($self->result->failure) {
+ if ( $self->result->failure ) {
Jifty->web->next_page("/check");
} else {
Jifty->web->next_page("/create");
Modified: Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/CreateReplica.pm
==============================================================================
--- Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/CreateReplica.pm (original)
+++ Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/CreateReplica.pm Mon Jul 21 16:44:19 2008
@@ -12,6 +12,6 @@
return $args;
}
-sub record_class { 'Pushmi::Admin::Model::Replica' }
+sub record_class {'Pushmi::Admin::Model::Replica'}
1;
Modified: Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/Remirror.pm
==============================================================================
--- Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/Remirror.pm (original)
+++ Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/Remirror.pm Mon Jul 21 16:44:19 2008
@@ -14,16 +14,16 @@
use Jifty::Action schema {
param replica =>
- type is 'integer',
- render as 'hidden',
- is mandatory;
+ type is 'integer',
+ render as 'hidden', is mandatory;
};
sub take_action {
my $self = shift;
- my $replica = Pushmi::Admin::Model::Replica->load($self->argument_value("replica"));
+ my $replica = Pushmi::Admin::Model::Replica->load(
+ $self->argument_value("replica") );
$replica->remirror;
}
Modified: Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/Sync.pm
==============================================================================
--- Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/Sync.pm (original)
+++ Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/Sync.pm Mon Jul 21 16:44:19 2008
@@ -14,25 +14,24 @@
use Jifty::Action schema {
param bootstrap =>
- type is 'file',
- label is "Bootstrap file";
+ type is 'file',
+ label is "Bootstrap file";
param replica =>
- type is 'integer',
- render as 'hidden',
- is mandatory;
+ type is 'integer',
+ render as 'hidden', is mandatory;
};
sub take_action {
my $self = shift;
- my $replica = Pushmi::Admin::Model::Replica->load($self->argument_value("replica"));
+ my $replica = Pushmi::Admin::Model::Replica->load(
+ $self->argument_value("replica") );
$replica->sync;
- if ($replica->status eq "behind") {
- $self->result->message( "Synchronization started" );
+ if ( $replica->status eq "behind" ) {
+ $self->result->message("Synchronization started");
}
}
1;
-
Modified: Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Dispatcher.pm
==============================================================================
--- Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Dispatcher.pm (original)
+++ Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Dispatcher.pm Mon Jul 21 16:44:19 2008
@@ -5,10 +5,13 @@
use Jifty::Dispatcher -base;
on '/create' => run {
- warn YAML::Dump(Jifty->web->response);
- if (Jifty->web->response->result("create") and Jifty->web->response->result("create")->success) {
- my $replica = Pushmi::Admin::Model::Replica->load(Jifty->web->response->result("create")->content("id"));
- redirect("/replica/" . $replica->clean_name);
+ warn YAML::Dump( Jifty->web->response );
+ if ( Jifty->web->response->result("create")
+ and Jifty->web->response->result("create")->success )
+ {
+ my $replica = Pushmi::Admin::Model::Replica->load(
+ Jifty->web->response->result("create")->content("id") );
+ redirect( "/replica/" . $replica->clean_name );
} else {
show "/create";
}
Modified: Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Model/HttpRoot.pm
==============================================================================
--- Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Model/HttpRoot.pm (original)
+++ Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Model/HttpRoot.pm Mon Jul 21 16:44:19 2008
@@ -8,12 +8,10 @@
use Pushmi::Admin::Record schema {
column path =>
- type is 'text',
- is mandatory,
- is unique;
+ type is 'text',
+ is mandatory, is unique;
- column replica_id =>
- refers_to Pushmi::Admin::Model::Replica;
+ column replica_id => refers_to Pushmi::Admin::Model::Replica;
};
Modified: Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Model/Replica.pm
==============================================================================
--- Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Model/Replica.pm (original)
+++ Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Model/Replica.pm Mon Jul 21 16:44:19 2008
@@ -17,22 +17,20 @@
use Pushmi::Admin::Record schema {
column name =>
- type is 'text',
- is mandatory,
- is unique;
+ type is 'text',
+ is mandatory, is unique;
column clean_name =>
- type is 'text',
- is protected;
+ type is 'text',
+ is protected;
column url =>
- type is 'text',
- is mandatory;
+ type is 'text',
+ is mandatory;
column status =>
- type is 'text',
- is protected,
- valid_values are [qw/loading ok behind offline failed/];
+ type is 'text',
+ is protected, valid_values are [qw/loading ok behind offline failed/];
};
@@ -41,10 +39,13 @@
my $name = shift;
my $dups = Pushmi::Admin::Model::ReplicaCollection->new;
- $dups->limit( column => 'clean_name', value => $self->_clean_name($name));
- $dups->limit( column => 'id', operator => '!=', value => $self->id)
- if $self->id;
- return (undef, "Duplicate name") if $dups->count;
+ $dups->limit(
+ column => 'clean_name',
+ value => $self->_clean_name($name)
+ );
+ $dups->limit( column => 'id', operator => '!=', value => $self->id )
+ if $self->id;
+ return ( undef, "Duplicate name" ) if $dups->count;
return 1;
}
@@ -60,31 +61,33 @@
sub after_set_name {
my $self = shift;
- $self->set_clean_name($self->_clean_name);
+ $self->set_clean_name( $self->_clean_name );
}
sub create {
my $self = shift;
- my %args = (@_, status => "failed");
+ my %args = ( @_, status => "failed" );
my $mirror = delete $args{mirror};
- my ($id, $msg) = $self->SUPER::create(%args);
+ my ( $id, $msg ) = $self->SUPER::create(%args);
if ($id) {
if ($mirror) {
my $http = Pushmi::Admin::Model::HttpRoot->new;
$http->create( path => $mirror, replica_id => $id );
}
- $self->set_clean_name($self->_clean_name);
+ $self->set_clean_name( $self->_clean_name );
- eval { Pushmi::Command::Mirror->new->run( $self->svn_root, $self->url ); };
+ eval {
+ Pushmi::Command::Mirror->new->run( $self->svn_root, $self->url );
+ };
my $err = $@;
warn $err if $err;
}
-
- return ($id, $msg);
+
+ return ( $id, $msg );
}
sub pushmi {
@@ -114,7 +117,8 @@
return if $self->pushmi->locked;
unless (fork) {
- exec($^X, Jifty->config->app("pushmi_bin"), "sync", $self->svn_root);
+ exec( $^X, Jifty->config->app("pushmi_bin"), "sync",
+ $self->svn_root );
}
}
@@ -131,11 +135,17 @@
my $start = Time::HiRes::time;
my $props;
- local $SIG{ALRM} = sub {die "Timeout!"};
+ local $SIG{ALRM} = sub { die "Timeout!" };
alarm 10;
eval {
- $client->info( $url, undef, "HEAD", sub { $props->{rev} = $_[1]->rev; $props->{date} = $_[1]->last_changed_date },
- 0 );
+ $client->info(
+ $url, undef, "HEAD",
+ sub {
+ $props->{rev} = $_[1]->rev;
+ $props->{date} = $_[1]->last_changed_date;
+ },
+ 0
+ );
};
warn "$@" if $@;
alarm 0;
@@ -146,50 +156,54 @@
sub remote_revision {
my $self = shift;
$self->status;
- return $CACHE{$self->id}{remote_revision};
+ return $CACHE{ $self->id }{remote_revision};
}
sub latency {
my $self = shift;
$self->status;
- return sprintf("%.2f seconds",$CACHE{$self->id}{latency});
+ return sprintf( "%.2f seconds", $CACHE{ $self->id }{latency} );
}
sub last_remote {
my $self = shift;
$self->status;
- return Time::Duration::duration(time - $CACHE{$self->id}{remote_date}/1e6) . " ago";
+ return Time::Duration::duration(
+ time - $CACHE{ $self->id }{remote_date} / 1e6 )
+ . " ago";
}
sub local_revision {
my $self = shift;
$self->status;
- return $CACHE{$self->id}{local_revision};
+ return $CACHE{ $self->id }{local_revision};
}
sub last_local {
my $self = shift;
$self->status;
- return Time::Duration::duration(time - $CACHE{$self->id}{local_date}/1e6) . " ago";
+ return Time::Duration::duration(
+ time - $CACHE{ $self->id }{local_date} / 1e6 )
+ . " ago";
}
sub svn_root {
- my $self = shift;
- my @parts = File::Spec->splitpath(Jifty->config->app('svn_root'));
- return File::Spec->catfile(@parts,$self->clean_name);
+ my $self = shift;
+ my @parts = File::Spec->splitpath( Jifty->config->app('svn_root') );
+ return File::Spec->catfile( @parts, $self->clean_name );
}
sub status {
my $self = shift;
- if ($self->id and not $CACHE{$self->id}) {
- my $c = $CACHE{$self->id} = {};
+ if ( $self->id and not $CACHE{ $self->id } ) {
+ my $c = $CACHE{ $self->id } = {};
my $local = $self->svn_info_for( "file://" . $self->svn_root );
my $remote = $self->svn_info_for( $self->url );
- if (not $local) {
+ if ( not $local ) {
$self->set_status("failed");
- } elsif (not $remote) {
- $c->{local_revision} = $local->{rev};
- $c->{local_date} = $local->{date};
+ } elsif ( not $remote ) {
+ $c->{local_revision} = $local->{rev};
+ $c->{local_date} = $local->{date};
$self->set_status("offline");
} else {
$c->{remote_revision} = $remote->{rev};
@@ -197,9 +211,9 @@
$c->{latency} = $remote->{latency};
$c->{local_revision} = $local->{rev};
$c->{local_date} = $local->{date};
- if ($self->pushmi->locked) {
+ if ( $self->pushmi->locked ) {
$self->set_status("loading");
- } elsif ($local->{rev} < $remote->{rev}) {
+ } elsif ( $local->{rev} < $remote->{rev} ) {
$self->set_status("behind");
} else {
$self->set_status("ok");
@@ -210,17 +224,29 @@
}
sub long_status {
- my $self = shift;
+ my $self = shift;
my $status = $self->status;
- if ($status eq "ok") {
- return "Up to date; mirrored ". $self->local_revision . " of ". $self->remote_revision . " revisions.";
- } elsif ($status eq "behind") {
- return "Lagging behind master; mirrored ". $self->local_revision . " of ". $self->remote_revision . " revisions.";
- } elsif ($status eq "loading") {
- return "Actively updating; mirrored ". $self->local_revision . " of ". $self->remote_revision . " revisions.";
- } elsif ($status eq "offline") {
- return "Remote master offline! Mirrored " . $self->local_revision . " revisions locally, last is " . $self->last_local;
- } elsif ($status eq "failed") {
+ if ( $status eq "ok" ) {
+ return "Up to date; mirrored "
+ . $self->local_revision . " of "
+ . $self->remote_revision
+ . " revisions.";
+ } elsif ( $status eq "behind" ) {
+ return "Lagging behind master; mirrored "
+ . $self->local_revision . " of "
+ . $self->remote_revision
+ . " revisions.";
+ } elsif ( $status eq "loading" ) {
+ return "Actively updating; mirrored "
+ . $self->local_revision . " of "
+ . $self->remote_revision
+ . " revisions.";
+ } elsif ( $status eq "offline" ) {
+ return "Remote master offline! Mirrored "
+ . $self->local_revision
+ . " revisions locally, last is "
+ . $self->last_local;
+ } elsif ( $status eq "failed" ) {
return "Local repository error!";
}
}
@@ -231,7 +257,7 @@
sub clear_cache {
%CACHE = ();
-};
+}
1;
Modified: Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/View.pm
==============================================================================
--- Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/View.pm (original)
+++ Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/View.pm Mon Jul 21 16:44:19 2008
@@ -11,13 +11,21 @@
$replicas->unlimit;
div {
{ id is 'replica_list', class is 'roundbox' };
- h2 { "Current replicas" };
- while (my $replica = $replicas->next) {
+ h2 {"Current replicas"};
+ while ( my $replica = $replicas->next ) {
div {
- { class is 'replica status-light '.$replica->status };
- h3 { hyperlink( url => "/replica/" . $replica->clean_name, label => $replica->name ) };
+ { class is 'replica status-light ' . $replica->status };
+ h3 {
+ hyperlink(
+ url => "/replica/" . $replica->clean_name,
+ label => $replica->name
+ );
+ };
hyperlink( url => $replica->url, label => $replica->url );
- div { { class is 'status' } $replica->long_status }
+ div {
+ { class is 'status' }
+ $replica->long_status;
+ }
}
}
};
@@ -25,35 +33,40 @@
add_replica();
};
-
template 'create' => page { title => "Create a new replica" } content {
my $result = Jifty->web->response->result("check");
my $data = $result ? $result->content("repository") : {};
- my $changed = DateTime->from_epoch( epoch => $data->{last_changed_date}/1e6 );
+ my $changed
+ = DateTime->from_epoch( epoch => $data->{last_changed_date} / 1e6 );
$changed->set_time_zone("EST");
div {
{ id is 'new_replica', class is 'roundbox' };
- h2 { "Add a new replica" };
+ h2 {"Add a new replica"};
div {
- {id is 'replica_status', class is 'roundbox'};
+ { id is 'replica_status', class is 'roundbox' };
h3 { $data->{repos_root_URL} }
- p { $data->{rev} . " revisions" }
- p { "Last modified on " . $changed->ymd . ", at " . $changed->hms }
+ p { $data->{rev} . " revisions" } p {
+ "Last modified on " . $changed->ymd . ", at " . $changed->hms;
+ }
};
form {
my $new = Jifty->web->new_action(
- class => "CreateReplica",
- moniker => "create",
- );
- if (my $prev = Jifty->web->request->action("check")) {
+ class => "CreateReplica",
+ moniker => "create",
+ );
+ if ( my $prev = Jifty->web->request->action("check") ) {
$new->argument_value( name => $prev->argument("name") );
- $new->argument_value( mirror => Pushmi::Admin::Model::Replica->_clean_name($prev->argument("name")));
+ $new->argument_value(
+ mirror => Pushmi::Admin::Model::Replica->_clean_name(
+ $prev->argument("name")
+ )
+ );
$new->argument_value( url => $data->{repos_root_URL} );
}
-
+
render_param( $new => "name" );
- outs_raw( $new->form_value( "url" ) );
+ outs_raw( $new->form_value("url") );
render_param( $new => "url", render_as => "hidden" );
render_param( $new => "mirror" );
form_submit( label => "Create" );
@@ -68,99 +81,122 @@
sub add_replica {
div {
{ id is 'new_replica', class is 'roundbox' };
- h2 { "Add a new replica" };
+ h2 {"Add a new replica"};
form {
my $check = Jifty->web->new_action(
- class => "CheckURL",
- moniker => "check",
+ class => "CheckURL",
+ moniker => "check",
sticky_on_failure => 1,
sticky_on_success => 1,
);
render_param( $check => "name" );
- render_param( $check => "url" );
+ render_param( $check => "url" );
form_submit( label => "Create" );
}
}
}
-template 'replica' => page { title => "About " . get("replica")->name } content {
+template 'replica' => page { title => "About " . get("replica")->name }
+ content {
my $replica = get 'replica';
div {
{ class is 'roundbox' };
- h2 { "Replica status" }
+ h2 {"Replica status"}
div {
- { class is 'replica status-light '.$replica->status };
- h3 { hyperlink( url => "/replica/" . $replica->clean_name, label => $replica->name ) };
+ { class is 'replica status-light ' . $replica->status };
+ h3 {
+ hyperlink(
+ url => "/replica/" . $replica->clean_name,
+ label => $replica->name
+ );
+ };
hyperlink( url => $replica->url, label => $replica->url );
- div { { class is 'status' } $replica->long_status }
+ div {
+ { class is 'status' }
+ $replica->long_status;
+ }
}
};
div {
{ class is 'roundbox' };
- if ($replica->status eq "behind" and $replica->local_revision == 0) {
- h2 { "Next step: mirroring" }
+ if ( $replica->status eq "behind" and $replica->local_revision == 0 )
+ {
+ h2 {"Next step: mirroring"}
p {
"The next step is to mirror all "
. $replica->remote_revision
- . " revisions from the remote mirror. This may take some time!"
+ . " revisions from the remote mirror. This may take some time!";
};
+
# p {
# "If you have a bootstrap file for this mirror, you can upload it below."
# };
form {
- my $sync = Jifty->web->new_action(
- class => "Sync",
- );
- render_param( $sync => "replica" => default_value => $replica->id );
+ my $sync = Jifty->web->new_action( class => "Sync", );
+ render_param(
+ $sync => "replica" => default_value => $replica->id );
form_submit( label => "Start mirroring" );
}
- } elsif ($replica->status ne "failed") {
- h2 { "Replica health" };
- p { "Last local commit: r" . $replica->local_revision ." - " . $replica->last_local };
- if ($replica->latency) {
- p { "Last master commit: r" . $replica->remote_revision ." - " . $replica->last_remote }
- p { "Latency to master: " . $replica->latency }
+ } elsif ( $replica->status ne "failed" ) {
+ h2 {"Replica health"};
+ p {
+ "Last local commit: r"
+ . $replica->local_revision . " - "
+ . $replica->last_local;
+ };
+ if ( $replica->latency ) {
+ p {
+ "Last master commit: r"
+ . $replica->remote_revision . " - "
+ . $replica->last_remote;
+ }
+ p { "Latency to master: " . $replica->latency };
}
form {
- my $sync = Jifty->web->new_action(
- class => "Sync",
- );
- render_param( $sync => "replica" => default_value => $replica->id );
+ my $sync = Jifty->web->new_action( class => "Sync", );
+ render_param(
+ $sync => "replica" => default_value => $replica->id );
form_submit( label => "Force an update now" );
}
} else {
- h2 { "Local replica failure" };
+ h2 {"Local replica failure"};
}
};
div {
{ id is 'advanced' }
- hyperlink( url => "/advanced/" . $replica->clean_name, label => "Advanced.." );
+ hyperlink(
+ url => "/advanced/" . $replica->clean_name,
+ label => "Advanced.."
+ );
}
}
-template 'advanced' => page { title => "Advanced configuration for ". get("replica")->name } content {
+template 'advanced' =>
+ page { title => "Advanced configuration for " . get("replica")->name }
+ content {
my $replica = get 'replica';
div {
{ class is 'roundbox' };
- h2 { "Advanced options for ". $replica->name ." replica" };
-
+ h2 { "Advanced options for " . $replica->name . " replica" };
+
form {
div {
{ class is "delete_replica" };
my $delete = $replica->as_delete_action;
outs_raw(
$delete->button(
- label => "Delete replica",
- url => "/",
- onclick => {
- confirm => 'Really delete this replica?',
- }
+ label => "Delete replica",
+ url => "/",
+ onclick =>
+ { confirm => 'Really delete this replica?', }
)
);
- p { "This will permanently remove the replica from this Pushmi server." };
+ p {
+ "This will permanently remove the replica from this Pushmi server."
+ };
}
div {
@@ -177,8 +213,10 @@
}
)
);
- p { "This will remove the replica, and immediately re-create it," .
- " remirroring all remote revisions. This is likely to take a while!" };
+ p {
+ "This will remove the replica, and immediately re-create it,"
+ . " remirroring all remote revisions. This is likely to take a while!";
+ };
}
};
}
More information about the Bps-public-commit
mailing list