[Bps-public-commit] r11573 - in SVN-PropDB: . doc lib/Prophet lib/Prophet/Handle t
jesse at bestpractical.com
jesse at bestpractical.com
Sat Apr 5 23:23:32 EDT 2008
Author: jesse
Date: Sat Apr 5 23:23:29 2008
New Revision: 11573
Modified:
SVN-PropDB/ (props changed)
SVN-PropDB/doc/todo
SVN-PropDB/lib/Prophet/CLI.pm
SVN-PropDB/lib/Prophet/Collection.pm
SVN-PropDB/lib/Prophet/Handle.pm
SVN-PropDB/lib/Prophet/Handle/SVN.pm
SVN-PropDB/lib/Prophet/Replica.pm
SVN-PropDB/lib/Prophet/Replica/Hiveminder.pm
SVN-PropDB/lib/Prophet/Replica/RT.pm
SVN-PropDB/lib/Prophet/Replica/SVN.pm
SVN-PropDB/t/canonicalize.t
SVN-PropDB/t/create.t
SVN-PropDB/t/validate.t
Log:
r29349 at 31b: jesse | 2008-04-05 17:22:52 -1000
* doc notes
* switch db_root to db_uuid, a unique id for a prophet _database_ (replicas are individual instances of databases)
* made collection not know or care about database uuids
* constantified the state database's uuid
* cleaned tests
Modified: SVN-PropDB/doc/todo
==============================================================================
--- SVN-PropDB/doc/todo (original)
+++ SVN-PropDB/doc/todo Sat Apr 5 23:23:29 2008
@@ -3,6 +3,24 @@
- write tests for RT-prophet-prophet-hiveminder sync
- implement uuids for prophet databases
+
+ - On initialization of an empty prophet replica
+ - get a uuid
+ - set replica's 'db_root' to _prophet-UUID
+
+
+
+ - how to mark two uuid as joined?
+ - merging between two replicas with different uuids is basically saying "I want to merge these two different databases"
+ - it should be possible to _change_ a replica's uuid. but maybe not for 0.1
+ - merging between replicas that were seperately initialized is to be treated as hm. "ow"
+
+
+
+ - and does it mean if the db is initialized with a pull, it uses the same UUID
+ - yes. in general, dbs should be initialized with pull or be new projects
+
+
- (use the uuid as a prefix for the db root?)
- each replica should know the uuid of the database it is a replica of
- merging between replicas with different uuids should require a 'force' argument of some kind.
Modified: SVN-PropDB/lib/Prophet/CLI.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/CLI.pm (original)
+++ SVN-PropDB/lib/Prophet/CLI.pm Sat Apr 5 23:23:29 2008
@@ -56,9 +56,9 @@
=cut
sub get_handle_for_replica {
- my ($self, $replica, $db_root) = @_;
+ my ($self, $replica, $db_uuid) = @_;
my $root = $ENV{'PROPHET_REPO'} || dir( $ENV{'HOME'}, '.prophet' ).'/_prophet_replica/'.$replica->uuid;
- return Prophet::Handle->new( repository => $root, db_root => $db_root );
+ return Prophet::Handle->new( repository => $root, db_uuid => $db_uuid);
}
=head2 _record_cmd
Modified: SVN-PropDB/lib/Prophet/Collection.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Collection.pm (original)
+++ SVN-PropDB/lib/Prophet/Collection.pm Sat Apr 5 23:23:29 2008
@@ -57,7 +57,7 @@
# find all items,
Carp::cluck unless defined $self->type;
- my $nodes = $self->handle->current_root->dir_entries( $self->handle->db_root . '/' . $self->type . '/' );
+ my $nodes = $self->handle->enumerate_nodes(type => $self->type);
# run coderef against each item;
# if it matches, add it to _items
Modified: SVN-PropDB/lib/Prophet/Handle.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Handle.pm (original)
+++ SVN-PropDB/lib/Prophet/Handle.pm Sat Apr 5 23:23:29 2008
@@ -10,7 +10,7 @@
our $DEBUG = 0;
-use constant db_root => '_prophet';
+use constant db_uuid => '_prophet';
=head2 new { repository => $FILESYSTEM_PATH}
Modified: SVN-PropDB/lib/Prophet/Handle/SVN.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Handle/SVN.pm (original)
+++ SVN-PropDB/lib/Prophet/Handle/SVN.pm Sat Apr 5 23:23:29 2008
@@ -20,7 +20,7 @@
my $self = {};
bless $self, $class;
- my %args = validate( @_, { repository => 1, db_root => 0 } );
+ my %args = validate( @_, { repository => 1, db_uuid => 0 } );
$self->repo_path( $args{'repository'} );
$self->_connect();
$self->_pool( SVN::Pool->new );
@@ -62,7 +62,7 @@
}
$self->repo_handle($repos);
- $self->_create_nonexistent_dir( $self->db_root );
+ $self->_create_nonexistent_dir( $self->db_uuid );
}
@@ -154,7 +154,7 @@
my $self = shift;
my %args = validate( @_, { uuid => 1, props => 1, type => 1 } );
- $self->_create_nonexistent_dir( join( '/', $self->db_root, $args{'type'} ) );
+ $self->_create_nonexistent_dir( join( '/', $self->db_uuid, $args{'type'} ) );
my $inside_edit = $self->current_edit ? 1 : 0;
$self->begin_edit() unless ($inside_edit);
@@ -281,7 +281,7 @@
my $self = shift;
my %args = validate( @_, { type => 1 } );
Carp::cluck unless defined $args{type};
- return join( "/", $self->db_root, $args{'type'} );
+ return join( "/", $self->db_uuid, $args{'type'} );
}
@@ -301,6 +301,12 @@
return $root->check_path( $self->file_for( uuid => $args{'uuid'}, type => $args{'type'} ) );
}
+sub enumerate_nodes {
+ my $self = shift;
+ my %args = validate(@_ => { type => 1 } );
+ return $self->current_root->dir_entries( $self->db_uuid . '/' . $args{type} . '/' );
+}
+
sub type_exists {
my $self = shift;
@@ -315,6 +321,3 @@
1;
-
-
-
Modified: SVN-PropDB/lib/Prophet/Replica.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Replica.pm (original)
+++ SVN-PropDB/lib/Prophet/Replica.pm Sat Apr 5 23:23:29 2008
@@ -8,6 +8,9 @@
__PACKAGE__->mk_accessors(qw(state_handle ressource is_resdb));
+use constant state_db_uuid => 'state';
+
+
=head1 NAME
Prophet::Replica
@@ -235,15 +238,15 @@
return $self->state_handle->_retrieve_metadata_for( $Prophet::Handle::MERGETICKET_METATYPE, $source, 'last-changeset' ) || 0;
- # the code below is attempting to get the content over ra so we
+ # XXXX the code below is attempting to get the content over ra so we
# can deal with remote svn repo. however this also assuming the
- # remote is having the same prophet_handle->db_root (which is
- # always empty for now.) the code to handle remote svn should be
+ # remote is having the same prophet_handle->db_rot
+ # the code to handle remote svn should be
# actually abstracted along when we design the sync prototype
my ( $stream, $pool );
- my $filename = join( "/", $self->prophet_handle->db_root, $Prophet::Handle::MERGETICKET_METATYPE, $source );
+ my $filename = join( "/", $self->prophet_handle->db_uuid, $Prophet::Handle::MERGETICKET_METATYPE, $source );
my ( $rev_fetched, $props )
= eval { $self->ra->get_file( $filename, $self->ra->get_latest_revnum, $stream, $pool ); };
Modified: SVN-PropDB/lib/Prophet/Replica/Hiveminder.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Replica/Hiveminder.pm (original)
+++ SVN-PropDB/lib/Prophet/Replica/Hiveminder.pm Sat Apr 5 23:23:29 2008
@@ -24,8 +24,6 @@
Open a connection to the SVN source identified by C<$self->url>.
-XXX TODO, make the _prophet/ directory in the replica configurable
-
=cut
use File::Temp 'tempdir';
@@ -55,7 +53,7 @@
$self->hm_username($username);
my $cli = Prophet::CLI->new();
- $self->state_handle( $cli->get_handle_for_replica( $self, 'state' ) );
+ $self->state_handle( $cli->get_handle_for_replica( $self, $self->state_db_uuid ) );
}
Modified: SVN-PropDB/lib/Prophet/Replica/RT.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Replica/RT.pm (original)
+++ SVN-PropDB/lib/Prophet/Replica/RT.pm Sat Apr 5 23:23:29 2008
@@ -71,8 +71,6 @@
Open a connection to the SVN source identified by C<$self->url>.
-XXX TODO, make the _prophet/ directory in the replica configurable
-
=cut
use File::Temp 'tempdir';
@@ -97,7 +95,7 @@
$self->rt->login( username => $username, password => $password );
my $cli = Prophet::CLI->new();
- $self->state_handle( $cli->get_handle_for_replica( $self, 'state' ) );
+ $self->state_handle( $cli->get_handle_for_replica( $self, $self->state_db_uuid ) );
}
Modified: SVN-PropDB/lib/Prophet/Replica/SVN.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Replica/SVN.pm (original)
+++ SVN-PropDB/lib/Prophet/Replica/SVN.pm Sat Apr 5 23:23:29 2008
@@ -24,8 +24,6 @@
Open a connection to the SVN source identified by C<$self->url>.
-XXX TODO, make the _prophet/ directory in the replica configurable
-
=cut
sub _get_ra {
Modified: SVN-PropDB/t/canonicalize.t
==============================================================================
--- SVN-PropDB/t/canonicalize.t (original)
+++ SVN-PropDB/t/canonicalize.t Sat Apr 5 23:23:29 2008
@@ -9,7 +9,7 @@
ok( !-d $REPO );
`svnadmin create $REPO`;
ok( -d $REPO, "The repo exists ater svnadmin create" );
-my $cxn = Prophet::Handle->new( repository => "$REPO", db_root => '/_propdb-test' );
+my $cxn = Prophet::Handle->new( repository => "$REPO");
isa_ok( $cxn, 'Prophet::Handle', "Got the cxn" );
use_ok('TestApp::Bug');
Modified: SVN-PropDB/t/create.t
==============================================================================
--- SVN-PropDB/t/create.t (original)
+++ SVN-PropDB/t/create.t Sat Apr 5 23:23:29 2008
@@ -10,7 +10,7 @@
diag($REPO);
`svnadmin create $REPO`;
ok( -d $REPO, "The repo exists ater svnadmin create" );
-my $cxn = Prophet::Handle->new( repository => "$REPO", db_root => '/_propdb-test' );
+my $cxn = Prophet::Handle->new( repository => "$REPO");
isa_ok( $cxn, 'Prophet::Handle', "Got the cxn" );
use_ok('Prophet::Record');
my $record = Prophet::Record->new( handle => $cxn, type => 'Person' );
Modified: SVN-PropDB/t/validate.t
==============================================================================
--- SVN-PropDB/t/validate.t (original)
+++ SVN-PropDB/t/validate.t Sat Apr 5 23:23:29 2008
@@ -10,7 +10,7 @@
ok( !-d $REPO );
`svnadmin create $REPO`;
ok( -d $REPO, "The repo exists ater svnadmin create" );
-my $cxn = Prophet::Handle->new( repository => "$REPO", db_root => '/_propdb-test' );
+my $cxn = Prophet::Handle->new( repository => "$REPO");
isa_ok( $cxn, 'Prophet::Handle', "Got the cxn" );
use_ok('TestApp::Bug');
More information about the Bps-public-commit
mailing list