[Bps-public-commit] r12051 - in Prophet/trunk: .
jesse at bestpractical.com
jesse at bestpractical.com
Sun May 4 16:54:14 EDT 2008
Author: jesse
Date: Sun May 4 16:54:13 2008
New Revision: 12051
Modified:
Prophet/trunk/ (props changed)
Prophet/trunk/lib/Prophet/App.pm
Prophet/trunk/lib/Prophet/ForeignReplica.pm
Prophet/trunk/lib/Prophet/Replica.pm
Prophet/trunk/lib/Prophet/Test.pm
Log:
r30427 at 245: jesse | 2008-05-04 16:53:11 -0400
* Encapsulated DEFAULT_REPLICA_TYPE
Modified: Prophet/trunk/lib/Prophet/App.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/App.pm (original)
+++ Prophet/trunk/lib/Prophet/App.pm Sun May 4 16:54:13 2008
@@ -38,6 +38,12 @@
}
}
+sub default_replica_type {
+ my $self = shift;
+ return $ENV{'PROPHET_REPLICA_TYPE'} || DEFAULT_REPLICA_TYPE;
+
+}
+
=head2 handle
@@ -47,7 +53,7 @@
my $self = shift;
unless ( $self->_handle() ) {
my $root = $ENV{'PROPHET_REPO'} || dir( $ENV{'HOME'}, '.prophet' );
- my $type = $ENV{'PROPHET_REPLICA_TYPE'} || DEFAULT_REPLICA_TYPE;
+ my $type = $self->default_replica_type;
$self->_handle( Prophet::Replica->new( { url => $type.':file://' . $root } ) );
}
return $self->_handle();
@@ -63,7 +69,7 @@
return ($self->handle->resolution_db_handle) if ($self->handle->resolution_db_handle);
unless ( $self->_resdb_handle ) {
my $root = ( $ENV{'PROPHET_REPO'} || dir( $ENV{'HOME'}, '.prophet' ) ) . "_res";
- my $type = $ENV{'PROPHET_REPLICA_TYPE'} || DEFAULT_REPLICA_TYPE;
+ my $type = $self->default_replica_type;
$self->_resdb_handle( Prophet::Replica->new( { url => $type.':file://' . $root } ) );
}
return $self->_resdb_handle();
Modified: Prophet/trunk/lib/Prophet/ForeignReplica.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/ForeignReplica.pm (original)
+++ Prophet/trunk/lib/Prophet/ForeignReplica.pm Sun May 4 16:54:13 2008
@@ -15,13 +15,22 @@
sub setup {
my $self = shift;
- my $cli = Prophet::CLI->new();
+ my $cli = Prophet::CLI->new();
- $self->state_handle( Prophet::Replica->new({ url => $ENV{'PROPHET_REPLICA_TYPE'} .":".$cli->app_handle->handle->url, db_uuid => $self->state_db_uuid }) );
+ # XXX TODO this $cli object should be a Prophet::App object
+ my $state_handle_url = $cli->app_handle->default_replica_type . ":" . $cli->app_handle->handle->url;
+ $self->log( "Connecting to state database ".$state_handle_url);
+ $self->state_handle(
+ Prophet::Replica->new(
+ { url => $state_handle_url,
+ db_uuid => $self->state_db_uuid
+ }
+ )
+ );
}
-sub conflicts_from_changeset { return; }
-sub can_write_changesets {1}
+sub conflicts_from_changeset { return; }
+sub can_write_changesets {1}
sub record_resolutions { die "not for foreign replicas" }
@@ -36,10 +45,8 @@
}
# XXX TODO = or do these ~always stay stubbed?
-sub begin_edit {}
-sub commit_edit{}
-
-
+sub begin_edit { }
+sub commit_edit { }
use Data::UUID 'NameSpace_DNS';
@@ -79,7 +86,8 @@
sub _remote_id_storage {
my $self = shift;
- return $self->state_handle->metadata_storage( $REMOTE_ID_METATYPE, 'prophet-uuid' )->(@_);
+ return $self->state_handle->metadata_storage( $REMOTE_ID_METATYPE,
+ 'prophet-uuid' )->(@_);
}
1;
Modified: Prophet/trunk/lib/Prophet/Replica.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Replica.pm (original)
+++ Prophet/trunk/lib/Prophet/Replica.pm Sun May 4 16:54:13 2008
@@ -73,14 +73,13 @@
sub _rebless_to_replica_type {
my $self = shift;
-
my ($scheme, $real_url) = split(/:/,$self->url,2);
$self->url($real_url);
if ( my $class = $Prophet::Replica::REPLICA_TYPE_MAP->{$scheme}) {
$class->require or die $@;
return bless $self, $class;
} else {
- die "$scheme isn't a replica type I know how to handle";
+ $self->log_fatal( "$scheme isn't a replica type I know how to handle. (The Replica URL given was ".$self->url.")");
}
}
@@ -773,5 +772,11 @@
}
+sub log_fatal {
+ my $self = shift;
+ $self->log(@_);
+ Carp::confess(@_);
+}
+
1;
Modified: Prophet/trunk/lib/Prophet/Test.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Test.pm (original)
+++ Prophet/trunk/lib/Prophet/Test.pm Sun May 4 16:54:13 2008
@@ -204,7 +204,7 @@
my $path = repo_path_for($username);
$path =~ s{^|\\}{/}g if IS_WIN32;
- return ($ENV{'PROPHET_REPLICA_TYPE'}|| Prophet::App->DEFAULT_REPLICA_TYPE) . ':file://' . $path;
+ return Prophet::App->default_replica_type . ':file://' . $path;
}
sub replica_uuid {
More information about the Bps-public-commit
mailing list