[Bps-public-commit] r11326 - in SVN-PropDB: bin lib/Prophet lib/Prophet/Sync/Source lib/Prophet/Test t
jesse at bestpractical.com
jesse at bestpractical.com
Tue Apr 1 00:14:47 EDT 2008
Author: jesse
Date: Tue Apr 1 00:14:41 2008
New Revision: 11326
Modified:
SVN-PropDB/ (props changed)
SVN-PropDB/bin/prophet-merge
SVN-PropDB/bin/prophet-node-update
SVN-PropDB/lib/Prophet/Sync/Source/SVN.pm
SVN-PropDB/lib/Prophet/Test.pm
SVN-PropDB/lib/Prophet/Test/Arena.pm
SVN-PropDB/lib/Prophet/Test/Participant.pm
SVN-PropDB/t/generalized_sync_n_merge.t
Log:
r28880 at 70-5-78-234: jesse | 2008-03-31 18:10:22 -1000
* much closer to running an n-way sync at the end of everything
Modified: SVN-PropDB/bin/prophet-merge
==============================================================================
--- SVN-PropDB/bin/prophet-merge (original)
+++ SVN-PropDB/bin/prophet-merge Tue Apr 1 00:14:41 2008
@@ -11,7 +11,7 @@
my $opts = {};
-GetOptions( $opts, 'from=s', 'to=s' );
+GetOptions( $opts, 'from=s', 'to=s', 'prefer=s');
validate_options($opts);
my $source = Prophet::Sync::Source->new( { url => $opts->{'from'} } );
@@ -27,7 +27,11 @@
fatal_error( $target->url . " does not accept changesets. Perhaps it's unwritable or something" );
}
-$target->import_changesets( from => $source );
+$target->import_changesets( from => $source,
+ use_resdb => 1,
+ ($opts->{'prefer'} eq 'to' ? (resolver => $target->always_mine_resolver) : ()),
+ ($opts->{'prefer'} eq 'from' ? (resolver => $target->always_theirs_resolver) : ())
+);
exit(0);
Modified: SVN-PropDB/bin/prophet-node-update
==============================================================================
--- SVN-PropDB/bin/prophet-node-update (original)
+++ SVN-PropDB/bin/prophet-node-update Tue Apr 1 00:14:41 2008
@@ -8,5 +8,3 @@
my $record = Prophet::Record->new(handle => $cli->handle, type => $cli->type);
$record->load(uuid => $cli->uuid);
$record->set_props(props => $cli->args);
-
-warn "We want more feedback here";
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 Tue Apr 1 00:14:41 2008
@@ -331,4 +331,15 @@
};
}
+
+sub always_theirs_resolver {
+ return
+ sub { my $conflict = shift;
+ return 0 if $conflict->file_op_conflict;
+
+ my $resolution = Prophet::Change->new_from_conflict( $conflict );
+ return $resolution;
+ };
+}
+
1;
Modified: SVN-PropDB/lib/Prophet/Test.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Test.pm (original)
+++ SVN-PropDB/lib/Prophet/Test.pm Tue Apr 1 00:14:41 2008
@@ -76,7 +76,7 @@
@_ = sub {
my ($ret, $stdout,$stderr) = (run_script($script, $args), $msg);
- @_ = ($ret);
+ @_ = ($ret,$msg);
goto &Test::More::ok;
};
goto \&lives_and;
Modified: SVN-PropDB/lib/Prophet/Test/Arena.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Test/Arena.pm (original)
+++ SVN-PropDB/lib/Prophet/Test/Arena.pm Tue Apr 1 00:14:41 2008
@@ -38,7 +38,21 @@
# for x rounds, have each participant execute a random action
}
+use List::MoreUtils qw/pairwise/;
+use List::Util qw/shuffle/;
sub sync_all_pairs {
+ my $self = shift;
+
+ my @chickens_a = shuffle(@{$self->chickens});
+ my @chickens_b = shuffle(@{$self->chickens});
+
+ pairwise {
+ warn $a;
+ warn $b;
+ return if $a->name eq $b->name;
+ $a->sync_from_peer($b);
+ } @chickens_a, @chickens_b;
+
}
Modified: SVN-PropDB/lib/Prophet/Test/Participant.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Test/Participant.pm (original)
+++ SVN-PropDB/lib/Prophet/Test/Participant.pm Tue Apr 1 00:14:41 2008
@@ -34,7 +34,6 @@
sub take_one_step {
my $self = shift;
my $action = shift || (shuffle(@CHICKEN_DO))[0];
- diag("We're taking a step: $action");
$self->$action();
@@ -80,7 +79,7 @@
}
sub create_record {
my $self = shift;
- run_ok('prophet-node-create', [qw(--type Scratch), _random_props() ], "Created a record");
+ run_ok('prophet-node-create', [qw(--type Scratch), _random_props() ], $self->name ." created a record");
}
sub update_record {
@@ -88,26 +87,23 @@
my $update_record = get_random_local_record();
my ($ok, $stdout, $stderr) = run_script('prophet-node-show', [qw(--type Scratch --uuid), $update_record]);
- diag($stdout);
my %props = map { split(/: /,$_,2) } split(/\n/,$stdout);
delete $props{id};
%props = _permute_props(%props);
- run_ok('prophet-node-update', [qw(--type Scratch --uuid), $update_record, map { '--'.$_ => $props{$_} } keys %props ], "Updated a record");
+ run_ok('prophet-node-update', [qw(--type Scratch --uuid), $update_record, map { '--'.$_ => $props{$_} } keys %props ], $self->name. " updated a record");
- diag($self->name, ' - update a record');
}
sub sync_from_peer {
my $self = shift;
- my $lucky = (shuffle(@{$self->arena->chickens}))[0];
+ my $lucky = shift || (shuffle(grep { $_->name ne $self->name} @{$self->arena->chickens}))[0];
# my $lucky = shift @peers;
- diag($self->name, ' - sync from a random peer - ' . $lucky->name);
- run_ok('prophet-merge', ['--from', repo_uri_for($lucky->name), '--to', repo_uri_for($self->name)], "Sync ran ok!");
+ run_ok('prophet-merge', ['--prefer','to','--from', repo_uri_for($lucky->name), '--to', repo_uri_for($self->name)], $self->name. " sync from " .$lucky->name." ran ok!");
@@ -124,4 +120,4 @@
sub dump_state {}
sub dump_history {}
-1;
\ No newline at end of file
+1;
Modified: SVN-PropDB/t/generalized_sync_n_merge.t
==============================================================================
--- SVN-PropDB/t/generalized_sync_n_merge.t (original)
+++ SVN-PropDB/t/generalized_sync_n_merge.t Tue Apr 1 00:14:41 2008
@@ -18,7 +18,7 @@
$arena->step();
}
-#$arena->sync_all_pairs;
+$arena->sync_all_pairs;
for (@{$arena->chickens}) {
warn $_->name;
@@ -37,6 +37,5 @@
});
}
-
exit;
;
More information about the Bps-public-commit
mailing list