[Bps-public-commit] r11542 - in SVN-PropDB/lib/Prophet: .

clkao at bestpractical.com clkao at bestpractical.com
Sat Apr 5 17:55:42 EDT 2008


Author: clkao
Date: Sat Apr  5 17:55:29 2008
New Revision: 11542

Modified:
   SVN-PropDB/lib/Prophet/Handle.pm
   SVN-PropDB/lib/Prophet/Replica/RT.pm
   SVN-PropDB/lib/Prophet/Replica/SVN.pm

Log:
refactor merge-ticket storage to use _record_metadata_for and 
_retrieve_metadata_for.


Modified: SVN-PropDB/lib/Prophet/Handle.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Handle.pm	(original)
+++ SVN-PropDB/lib/Prophet/Handle.pm	Sat Apr  5 17:55:29 2008
@@ -157,23 +157,39 @@
 sub _record_merge_ticket {
     my $self = shift;
     my ( $source_uuid, $sequence_no ) = validate_pos( @_, 1, 1 );
+    return $self->_record_metadata_for( $MERGETICKET_METATYPE, $source_uuid, 'last-changeset', $sequence_no);
+}
+
+sub _retrieve_metadata_for {
+    my $self = shift;
+    my ( $name, $source_uuid, $prop_name ) = validate_pos( @_, 1, 1, 1 );
+
+    my $entry = Prophet::Record->new( handle => $self, type => $name );
+    $entry->load(uuid => $source_uuid);
+    return eval { $entry->prop($prop_name) };
+
+}
 
-    my $props = eval { $self->get_node_props( uuid => $source_uuid, type => $MERGETICKET_METATYPE ) };
-    unless ( $props->{'last-changeset'} ) {
-        eval { $self->create_node( uuid => $source_uuid, type => $MERGETICKET_METATYPE, props => {} ) };
+sub _record_metadata_for {
+    my $self = shift;
+    my ( $name, $source_uuid, $prop_name, $content ) = validate_pos( @_, 1, 1, 1, 1 );
+
+    my $props = eval { $self->get_node_props( uuid => $source_uuid, type => $name ) };
+
+    # XXX: do set-prop when exists, and just create new node with all props is probably better
+    unless ( $props->{$prop_name} ) {
+        eval { $self->create_node( uuid => $source_uuid, type => $name, props => {} ) };
     }
 
     $self->set_node_props(
         uuid => $source_uuid,
-        type => $MERGETICKET_METATYPE,
-        props => { 'last-changeset' => $sequence_no }
+        type => $name,
+        props => { $prop_name => $content }
     );
-
 }
 
 
 
-
 use YAML::Syck;
 
 package YAML;

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 17:55:29 2008
@@ -210,7 +210,7 @@
     my ($id) = validate_pos(@_, 1);
     
     my $remote_id = Prophet::Record->new( handle => $self->state_handle, type => $REMOTE_ID_METATYPE);
-  $remote_id->load(uuid => $self->uuid_for_url( $self->rt_url . "/ticket/$id" )); # FAILURE IS OK
+    $remote_id->load(uuid => $self->uuid_for_url( $self->rt_url . "/ticket/$id" ));
     return eval {$remote_id->prop('prophet-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 17:55:29 2008
@@ -154,6 +154,15 @@
 sub last_changeset_from_source {
     my $self = shift;
     my ($source) = validate_pos( @_, { type => SCALAR } );
+
+    return $self->prophet_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
+    # 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
+    # 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 );



More information about the Bps-public-commit mailing list