[Bps-public-commit] r11291 - in SVN-PropDB: lib/Prophet t
clkao at bestpractical.com
clkao at bestpractical.com
Mon Mar 31 04:58:15 EDT 2008
Author: clkao
Date: Mon Mar 31 04:58:15 2008
New Revision: 11291
Added:
SVN-PropDB/t/real-conflicting-merge.t
Modified:
SVN-PropDB/lib/Prophet/Change.pm
SVN-PropDB/lib/Prophet/Conflict.pm
SVN-PropDB/lib/Prophet/Sync/Source/SVN.pm
Log:
"always mine" resolver in real-conflictin-merge.t.
Modified: SVN-PropDB/lib/Prophet/Change.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Change.pm (original)
+++ SVN-PropDB/lib/Prophet/Change.pm Mon Mar 31 04:58:15 2008
@@ -41,7 +41,7 @@
sub prop_changes {
my $self = shift;
- return @{$self->{prop_changes}||[]};
+ return @{$self->{prop_changes}};
}
Modified: SVN-PropDB/lib/Prophet/Conflict.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Conflict.pm (original)
+++ SVN-PropDB/lib/Prophet/Conflict.pm Mon Mar 31 04:58:15 2008
@@ -32,7 +32,7 @@
sub _resolution_failed {
- return sub { die "conflict not resolved." };
+ return sub { die "conflict not resolved.\n" };
}
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 Mon Mar 31 04:58:15 2008
@@ -71,7 +71,7 @@
return $last_editor;
};
- my $first_rev = $args{'after'} || 1;
+ my $first_rev = ( $args{'after'}+1) || 1;
# XXX TODO we should be using a svn get_log call here rather than simple iteration
# clkao explains that this won't deal cleanly with cases where there are revision "holes"
@@ -250,12 +250,10 @@
if (my $conflict = $self->conflicts_from_changeset($changeset ) ) {
$args{conflict_callback}->($conflict) if $args{'conflict_callback'};
- $conflict->resolver(sub { $args{resolver}->(@_) }) if $args{resolver};
+ $conflict->resolvers([sub { $args{resolver}->(@_) }]) if $args{resolver};
my $resolutions = $conflict->generate_resolution;
Carp::cluck;
#figure out our conflict resolution
-
-
# IMPORTANT: these should be an atomic unit. dying here would be poor. BUT WE WANT THEM AS THREEDIFFERENT SVN REVS
# integrate the nullification change
@@ -264,7 +262,7 @@
# integrate the original change
$self->prophet_handle->integrate_changeset($changeset);
# integrate the conflict resolution change
- $self->prophet_handle->record_changeset($conflict->resolution_changeset);
+ $self->prophet_handle->record_changeset($conflict->resolution_changeset);
} else {
Added: SVN-PropDB/t/real-conflicting-merge.t
==============================================================================
--- (empty file)
+++ SVN-PropDB/t/real-conflicting-merge.t Mon Mar 31 04:58:15 2008
@@ -0,0 +1,101 @@
+#!/usr/bin/perl
+#
+use warnings;
+use strict;
+use Test::Exception;
+
+use Prophet::Test tests => 12;
+
+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");
+ };
+
+
+diag('Bob syncs from alice');
+
+my $record_id;
+
+as_bob {
+
+ run_ok('prophet-node-create', [qw(--type Dummy --ignore yes)], "Created a dummy record");
+
+ run_ok('prophet-merge', ['--to', repo_uri_for('bob'), '--from', repo_uri_for('alice')], "Sync ran ok!");
+ # check our local replicas
+ my ($ret, $out, $err) = run_script('prophet-node-search', [qw(--type Bug --regex .)]);
+ like($out, qr/new/, "We have the one node from alice") ;
+ if ($out =~ /^(.*?)\s./) {
+ $record_id = $1;
+ }
+ diag($record_id);
+
+ run_ok('prophet-node-update', ['--type','Bug','--uuid',$record_id, '--status' => 'stalled']);
+ run_output_matches('prophet-node-show', ['--type', 'Bug', '--uuid', $record_id],
+ ['id: '.$record_id, 'status: stalled', 'from: alice'],
+ 'content is correct');
+};
+
+as_alice {
+ run_ok('prophet-node-update', ['--type','Bug','--uuid',$record_id, '--status' => 'open']);
+ run_output_matches('prophet-node-show', ['--type', 'Bug', '--uuid', $record_id],
+ ['id: '.$record_id, 'status: open', 'from: alice'],
+ 'content is correct');
+
+};
+
+# This conflict, we can autoresolve
+
+as_bob {
+ # XXX TODO: this should actually fail right now.
+ # in perl code, we're going to run the merge (just as prophet-merge does)
+
+ use_ok('Prophet::Sync::Source::SVN' );
+
+ my $source = Prophet::Sync::Source->new( { url => repo_uri_for('alice') } );
+ my $target = Prophet::Sync::Source->new( { url => repo_uri_for('bob')} );
+
+ my $conflict_obj;
+
+ throws_ok {
+ $target->import_changesets(
+ from => $source,
+ );
+ } qr/not resolved/;
+
+ throws_ok {
+ $target->import_changesets(
+ from => $source,
+ resolver => sub { die "my way of death\n" },
+ );
+ } qr/my way of death/, 'our resolver is actually called';
+
+# always ours
+use Data::Dumper;
+ $target->import_changesets(
+ from => $source,
+ resolver => sub { my $conflict = shift;
+ warn Dumper($conflict);
+ return 0 if $conflict->file_op_conflict;
+
+ my $resolution = Prophet::Change->new( { is_resolution => 1,
+ change_type => $conflict->change_type,
+ node_type => $conflict->node_type,
+ node_uuid => $conflict->node_uuid });
+
+
+ for my $prop_conflict ( @{$conflict->prop_conflicts} ) {
+ $resolution->add_prop_change(
+ name => $prop_conflict->name,
+ old => $prop_conflict->source_old_value,
+ new => $prop_conflict->target_value
+ );
+ }
+ return $resolution;
+
+});
+my $repo = repo_uri_for('bob');
+diag `svn log -v $repo`;
+
+};
+
+
More information about the Bps-public-commit
mailing list