[Bps-public-commit] r11596 - in SVN-PropDB: lib/Prophet t

clkao at bestpractical.com clkao at bestpractical.com
Sun Apr 6 08:03:54 EDT 2008


Author: clkao
Date: Sun Apr  6 08:03:52 2008
New Revision: 11596

Modified:
   SVN-PropDB/lib/Prophet/Replica.pm
   SVN-PropDB/lib/Prophet/Replica/HTTP.pm
   SVN-PropDB/t/export.t

Log:
pack in uuid from value not hex.


Modified: SVN-PropDB/lib/Prophet/Replica.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Replica.pm	(original)
+++ SVN-PropDB/lib/Prophet/Replica.pm	Sun Apr  6 08:03:52 2008
@@ -557,7 +557,7 @@
         # and then converting. this is wasteful
         print $cs_file pack( 'Na16Na20',
             $changeset->sequence_no,
-            $changeset->original_source_uuid,
+            Data::UUID->new->from_string( $changeset->original_source_uuid ),
             $changeset->original_sequence_no,
             sha1($content) )
             || die $!;

Modified: SVN-PropDB/lib/Prophet/Replica/HTTP.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Replica/HTTP.pm	(original)
+++ SVN-PropDB/lib/Prophet/Replica/HTTP.pm	Sun Apr  6 08:03:52 2008
@@ -10,7 +10,7 @@
 use Prophet::ChangeSet;
 use Prophet::Conflict;
 
-__PACKAGE__->mk_accessors(qw/url db_uuid/);
+__PACKAGE__->mk_accessors(qw/url db_uuid _uuid/);
 
 our $DEBUG = $Prophet::Handle::DEBUG;
 
@@ -41,7 +41,9 @@
 
 sub uuid {
     my $self = shift;
-    return LWP::Simple::get($self->url.'/replica-uuid');
+
+    $self->_uuid( LWP::Simple::get($self->url.'/replica-uuid') ) unless $self->_uuid;
+    return $self->_uuid ;
 }
 
 =head2 fetch_changesets { after => SEQUENCE_NO } 
@@ -73,18 +75,18 @@
         my ($seq, $orig_uuid, $orig_seq, $key)
             = unpack('Na16NH40', substr( $chgidx, ($rev-1)*CHG_RECORD_SIZE, CHG_RECORD_SIZE ) );
         $orig_uuid = Data::UUID->new->to_string( $orig_uuid );
-        warn "($key)";
+
         # XXX: deserialize the changeset content from the cas with $key
         my $casfile = $self->url.'/cas/'.substr($key, 0, 1).'/'.substr($key, 1, 1).'/'.$key;
-        warn $casfile;
+
         my $content = YAML::Syck::Load(LWP::Simple::get($casfile));
-        warn Dumper($content);use Data::Dumper;
+
         my $changeset = Prophet::ChangeSet->new_from_hashref( $content );
         $changeset->source_uuid($self->uuid);
         $changeset->sequence_no($seq);
         $changeset->original_source_uuid( $orig_uuid);
         $changeset->original_sequence_no( $orig_seq);
-
+        warn Dumper($changeset);use Data::Dumper;
         push @results, $changeset;
     }
 

Modified: SVN-PropDB/t/export.t
==============================================================================
--- SVN-PropDB/t/export.t	(original)
+++ SVN-PropDB/t/export.t	Sun Apr  6 08:03:52 2008
@@ -4,7 +4,7 @@
 use strict;
 use Test::Exception;
 
-use Prophet::Test tests => 12;
+use Prophet::Test tests => 16;
 use Test::Exception;
 
 as_alice {
@@ -57,6 +57,7 @@
     use_ok('Prophet::Replica::HTTP');
     my $changesets = Prophet::Replica->new({ url => 'prophet:file://'.$path} )->fetch_changesets( after => 0 );
     is( $#{ $changesets}, 4, "We found a total of 5 changesets");
+    is(lc($changesets->[-1]->{source_uuid}), lc($changesets->[-1]->{original_source_uuid}));
 
 };
 



More information about the Bps-public-commit mailing list