[Bps-public-commit] r11277 - in SVN-PropDB: . bin lib/Prophet t

jesse at bestpractical.com jesse at bestpractical.com
Sun Mar 30 18:06:48 EDT 2008


Author: jesse
Date: Sun Mar 30 18:06:47 2008
New Revision: 11277

Modified:
   SVN-PropDB/   (props changed)
   SVN-PropDB/bin/prophet-merge
   SVN-PropDB/lib/Prophet/Handle.pm
   SVN-PropDB/lib/Prophet/Sync/Source/SVN.pm
   SVN-PropDB/lib/Prophet/Test.pm
   SVN-PropDB/t/cli.t

Log:
 r28806 at 68-246-21-112:  jesse | 2008-03-30 12:05:56 -1000
 * repeated syncs from the same peer succeed
 


Modified: SVN-PropDB/bin/prophet-merge
==============================================================================
--- SVN-PropDB/bin/prophet-merge	(original)
+++ SVN-PropDB/bin/prophet-merge	Sun Mar 30 18:06:47 2008
@@ -12,8 +12,8 @@
 GetOptions( $opts, 'from=s', 'to=s' );
 validate_options($opts);
 
-my $target = Prophet::Sync::Source->new( { url => $opts->{'from'} } );
-my $source = Prophet::Sync::Source->new( { url => $opts->{'to'} } );
+my $source = Prophet::Sync::Source->new( { url => $opts->{'from'} } );
+my $target = Prophet::Sync::Source->new( { url => $opts->{'to'} } );
 
 if ( $target->uuid eq $source->uuid ) {
     fatal_error( "You appear to be trying to merge two identical replicas. "
@@ -52,7 +52,9 @@
         = $source->fetch_changesets( after => $target->last_changeset_from_source( $source->uuid ) );
 
     for my $changeset (@$changesets_to_integrate) {
-        next if ( $target->has_seen_changeset($changeset) );
+     use Data::Dumper; warn Dumper($changeset);
+     
+       next if ( $target->has_seen_changeset($changeset) );
         if ( $target->changeset_will_conflict($changeset) ) {
 
             my $conflicts = $target->conflicts_from_changeset($changeset);

Modified: SVN-PropDB/lib/Prophet/Handle.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Handle.pm	(original)
+++ SVN-PropDB/lib/Prophet/Handle.pm	Sun Mar 30 18:06:47 2008
@@ -11,6 +11,7 @@
 use SVN::Repos;
 use SVN::Fs;
 
+our $DEBUG = '0';
 __PACKAGE__->mk_accessors(qw(repo_path repo_handle db_root current_edit));
 
 
@@ -111,9 +112,14 @@
     my $self      = shift;
     my $changeset = shift;
 
+    warn "==> attmping to integrate changeset $changeset";
     $self->begin_edit();
     $self->_integrate_change($_) for ($changeset->changes);
     $self->_set_original_source_metadata($changeset);
+    warn "to commit... " if ($DEBUG);
+    my $changed = $self->current_edit->root->paths_changed;
+    warn Dumper($changed) if ($DEBUG);
+    $self->record_changeset_integration($changeset);
     $self->commit_edit();
 }
 
@@ -133,7 +139,7 @@
     my $change = shift;
 
     my %new_props = map { $_->name => $_->new_value } $change->prop_changes;
-
+ 
     if ( $change->change_type eq 'add_file' ) {
         $self->create_node(
             type  => $change->node_type,
@@ -153,6 +159,8 @@
             uuid => $change->node_uuid
         );
     }
+    my $changed = $self->current_edit->root->paths_changed;
+    
 }
 
 =head2 create_node { type => $TYPE, uuid => $uuid, props => { key-value pairs }}

Modified: SVN-PropDB/lib/Prophet/Sync/Source/SVN.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Sync/Source/SVN.pm	(original)
+++ SVN-PropDB/lib/Prophet/Sync/Source/SVN.pm	Sun Mar 30 18:06:47 2008
@@ -179,7 +179,6 @@
 
 }
 
-
 =head2 conflicts_from_changeset Prophet::ChangeSet
 
 Returns a L<Prophet::Conflict/> object if the supplied L<Prophet::ChangeSet/>
@@ -198,7 +197,7 @@
     $conflict->analyze_changeset($changeset);
     
 
-    return undef unless $#{$conflict->conflicting_changes()};
+    return undef unless @{$conflict->conflicting_changes};
 
     return $conflict;
 

Modified: SVN-PropDB/lib/Prophet/Test.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Test.pm	(original)
+++ SVN-PropDB/lib/Prophet/Test.pm	Sun Mar 30 18:06:47 2008
@@ -8,6 +8,7 @@
 use File::Temp qw/tempdir/;
 use Path::Class 'dir';
 use Test::Exception;
+use IPC::Run3 'run3';
 
 
 our $REPO_BASE = File::Temp::tempdir();
@@ -37,9 +38,14 @@
 
 sub run_script {
     my $script = shift;
-    system($^X, (map { "-I$_" } @INC), 'bin/'.$script, @_);
+    my $args = shift;
+    my ($stdout, $stderr);
+    my @cmd = ($^X, (map { "-I$_" } @INC), 'bin/'.$script);
+
+    my $ret = run3 [@cmd, @$args], undef, \$stdout, \$stderr;
+
     Carp::croak $! if $?;
-    return;
+    return($ret, $stdout, $stderr);
 }
 
 =head2 run_ok SCRIPT_NAME [@ARGS] (<- optional hashref), optional message
@@ -55,7 +61,9 @@
    
    lives_and {
    
-      @_ = (run_script($script, @$args), $msg);
+      my ($ret, $stdout,$stderr) = (run_script($script, $args), $msg);
+      @_ = ($ret);
+      diag($stderr);
       goto &Test::More::ok;
 };
 }
@@ -78,7 +86,6 @@
     }
 }
 
-use IPC::Run3 'run3';
 
 =head2 is_script_output SCRIPTNAME \@ARGS, \@STDOUT_MATCH, \@STDERR_MATCH, $MSG
 
@@ -179,7 +186,7 @@
 
 END {
     for (qw(alice bob charlie david)) {
-        as_user( $_, sub { rmtree [ $ENV{'PROPHET_REPO'} ] } );
+   #     as_user( $_, sub { rmtree [ $ENV{'PROPHET_REPO'} ] } );
     }
 }
 

Modified: SVN-PropDB/t/cli.t
==============================================================================
--- SVN-PropDB/t/cli.t	(original)
+++ SVN-PropDB/t/cli.t	Sun Mar 30 18:06:47 2008
@@ -3,7 +3,10 @@
 use warnings;
 use strict;
 
-use Prophet::Test tests => 7;
+use Prophet::Test tests => 19;
+
+use_ok('Prophet::CLI');
+
 as_alice {
     run_ok('prophet-node-create', [qw(--type Bug --status new --from alice )], "Created a record as alice"); 
     run_output_matches('prophet-node-search', [qw(--type Bug --regex .)], [qr/new/], " Found our record");
@@ -25,12 +28,46 @@
 as_alice {
     # sync from bob
     run_ok('prophet-merge', ['--from', Prophet::Test::repo_uri_for('bob'), '--to', Prophet::Test::repo_uri_for('alice')], "Sync ran ok!");
-    # check our local replica
-      my ($out, $err) = run_script('prophet-node-search', [qw(--type Bug --regex .)]);
-      like_ok($out, qr/open/) ;
-      like_ok($out, qr/new/) ;
+    # check our local replicas
+    my ($ret, $out, $err) = run_script('prophet-node-search', [qw(--type Bug --regex .)]);
+    like($out, qr/open/) ;
+    like($out, qr/new/) ;
+    my @out = split(/\n/,$out);
+    is (scalar @out, 2, "We found only two rows of output");
+    
+    my $cli = Prophet::CLI->new();
+    isa_ok($cli->handle, 'Prophet::Handle');
+
+    my $last_rev = $cli->handle->repo_handle->fs->youngest_rev;
+
+    diag("Rerun the exact same sync operation. we should still only end up with two records and NO new transactions");
+
+    # sync from bob
+    run_ok('prophet-merge', ['--from', Prophet::Test::repo_uri_for('bob'), '--to', Prophet::Test::repo_uri_for('alice')], "Sync ran ok!");
+    # check our local replicas
+    ($ret, $out, $err) = run_script('prophet-node-search', [qw(--type Bug --regex .)]);
+    like($out, qr/open/) ;
+    like($out, qr/new/) ;
+    @out = split(/\n/,$out);
+    is (scalar @out, 2, "We found only two rows of output");
+
+    is( $cli->handle->repo_handle->fs->youngest_rev, $last_rev, "We have not recorded another transaction");
+    
+};
+
+
 
 
+as_bob {
+    my ($ret, $out, $err) = run_script('prophet-node-search', [qw(--type Bug --regex .)]);
+    unlike($out, qr/new/, "bob doesn't have alice's yet") ;
+
+    # sync from bob
+    run_ok('prophet-merge', ['--to', Prophet::Test::repo_uri_for('bob'), '--from', Prophet::Test::repo_uri_for('alice')], "Sync ran ok!");
+    # check our local replicas
+    ($ret, $out, $err) = run_script('prophet-node-search', [qw(--type Bug --regex .)]);
+    like($out, qr/open/) ;
+    like($out, qr/new/) ;
 };
 
 



More information about the Bps-public-commit mailing list