[Bps-public-commit] r11574 - in SVN-PropDB: . doc lib/Prophet/Handle
jesse at bestpractical.com
jesse at bestpractical.com
Sat Apr 5 23:57:11 EDT 2008
Author: jesse
Date: Sat Apr 5 23:56:48 2008
New Revision: 11574
Modified:
SVN-PropDB/ (props changed)
SVN-PropDB/doc/todo
SVN-PropDB/lib/Prophet/Collection.pm
SVN-PropDB/lib/Prophet/Handle.pm
SVN-PropDB/lib/Prophet/Handle/SVN.pm
Log:
r29351 at 31b: jesse | 2008-04-05 17:56:05 -1000
* Databases now have unique ids.
Modified: SVN-PropDB/doc/todo
==============================================================================
--- SVN-PropDB/doc/todo (original)
+++ SVN-PropDB/doc/todo Sat Apr 5 23:56:48 2008
@@ -9,19 +9,20 @@
- set replica's 'db_root' to _prophet-UUID
+ - how do we tell prophet what db uuid it wants to use if there are two of them? or do we expect one replica to only ever have one database?
- 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"
-
+ - sane?
- 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?)
+ - (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/Collection.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Collection.pm (original)
+++ SVN-PropDB/lib/Prophet/Collection.pm Sat Apr 5 23:56:48 2008
@@ -61,7 +61,7 @@
# run coderef against each item;
# if it matches, add it to _items
- foreach my $key ( sort keys %$nodes ) {
+ foreach my $key ( @$nodes) {
my $record = $self->record_class->new( { handle => $self->handle, type => $self->type } );
$record->load( uuid => $key );
if ( $coderef->($record) ) {
Modified: SVN-PropDB/lib/Prophet/Handle.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Handle.pm (original)
+++ SVN-PropDB/lib/Prophet/Handle.pm Sat Apr 5 23:56:48 2008
@@ -9,8 +9,7 @@
our $DEBUG = 0;
-
-use constant db_uuid => '_prophet';
+__PACKAGE__->mk_accessors(qw/db_uuid/);
=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:56:48 2008
@@ -22,6 +22,7 @@
my %args = validate( @_, { repository => 1, db_uuid => 0 } );
$self->repo_path( $args{'repository'} );
+ $self->db_uuid($args{'db_uuid'}) if ($args{'db_uuid'});
$self->_connect();
$self->_pool( SVN::Pool->new );
return $self;
@@ -61,8 +62,33 @@
$repos = SVN::Repos::create( $self->repo_path, undef, undef, undef, undef, $self->_pool );
}
+
$self->repo_handle($repos);
- $self->_create_nonexistent_dir( $self->db_uuid );
+ $self->_determine_db_uuid;
+ $self->_create_nonexistent_dir($self->db_uuid);
+}
+
+use constant USER_PROVIDED_DB_UUID => 1;
+use constant DETECTED_DB_UUID => 2;
+use constant CREATED_DB_UUID => 3;
+
+
+sub _determine_db_uuid {
+ my $self = shift;
+ return USER_PROVIDED_DB_UUID if $self->db_uuid;
+ my @known_replicas = keys %{ $self->current_root->dir_entries("/") };
+
+ for my $key ( keys %{ $self->current_root->dir_entries("/") } ) {
+ if ( $key =~ /^_prophet-/ ) {
+ $self->db_uuid($key);
+ return DETECTED_DB_UUID;
+ }
+ }
+
+ # no luck. create one
+
+ $self->db_uuid( "_prophet-" . Data::UUID->new->create_str() );
+ return CREATED_DB_UUID;
}
@@ -304,7 +330,7 @@
sub enumerate_nodes {
my $self = shift;
my %args = validate(@_ => { type => 1 } );
- return $self->current_root->dir_entries( $self->db_uuid . '/' . $args{type} . '/' );
+ return [ keys %{ $self->current_root->dir_entries( $self->db_uuid . '/' . $args{type} . '/' )}];
}
More information about the Bps-public-commit
mailing list