[Bps-public-commit] r11349 - in SVN-PropDB: bin lib/Prophet lib/Prophet/Resolver lib/Prophet/Sync lib/Prophet/Sync/Resolver lib/Prophet/Sync/Source t
jesse at bestpractical.com
jesse at bestpractical.com
Tue Apr 1 20:18:21 EDT 2008
Author: jesse
Date: Tue Apr 1 20:18:19 2008
New Revision: 11349
Added:
SVN-PropDB/lib/Prophet/Resolver/
SVN-PropDB/lib/Prophet/Resolver.pm
SVN-PropDB/lib/Prophet/Resolver/AlwaysSource.pm
SVN-PropDB/lib/Prophet/Resolver/AlwaysTarget.pm
Removed:
SVN-PropDB/lib/Prophet/Sync/Resolver/
Modified:
SVN-PropDB/ (props changed)
SVN-PropDB/bin/prophet-merge
SVN-PropDB/lib/Prophet/Sync/Source.pm
SVN-PropDB/lib/Prophet/Sync/Source/SVN.pm
SVN-PropDB/t/real-conflicting-merge.t
Log:
r28918 at 70-5-79-205: jesse | 2008-04-01 14:17:53 -1000
* Extracted resolvers
Modified: SVN-PropDB/bin/prophet-merge
==============================================================================
--- SVN-PropDB/bin/prophet-merge (original)
+++ SVN-PropDB/bin/prophet-merge Tue Apr 1 20:18:19 2008
@@ -29,8 +29,8 @@
$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) : ())
+ ($opts->{'prefer'} eq 'to' ? (resolver_class => 'Prophet::Resolver::AlwaysTarget') : ()),
+ ($opts->{'prefer'} eq 'from' ? (resolver_class => 'Prophet::Resolver::AlwaysSource') : ())
);
exit(0);
Added: SVN-PropDB/lib/Prophet/Resolver.pm
==============================================================================
--- (empty file)
+++ SVN-PropDB/lib/Prophet/Resolver.pm Tue Apr 1 20:18:19 2008
@@ -0,0 +1,13 @@
+use warnings;
+use strict;
+
+package Prophet::Resolver;
+
+sub new {
+ my $class = shift;
+ my $self = bless {}, $class;
+ return $self;
+}
+
+1;
+
Added: SVN-PropDB/lib/Prophet/Resolver/AlwaysSource.pm
==============================================================================
--- (empty file)
+++ SVN-PropDB/lib/Prophet/Resolver/AlwaysSource.pm Tue Apr 1 20:18:19 2008
@@ -0,0 +1,17 @@
+use warnings;
+use strict;
+
+package Prophet::Resolver::AlwaysSource;
+use base qw/Prophet::Resolver/;
+use Prophet::Change;
+
+sub run {
+ my $self = shift;
+ my $conflict = shift;
+ return 0 if $conflict->file_op_conflict;
+
+ my $resolution = Prophet::Change->new_from_conflict($conflict);
+ return $resolution;
+}
+
+1;
Added: SVN-PropDB/lib/Prophet/Resolver/AlwaysTarget.pm
==============================================================================
--- (empty file)
+++ SVN-PropDB/lib/Prophet/Resolver/AlwaysTarget.pm Tue Apr 1 20:18:19 2008
@@ -0,0 +1,26 @@
+use warnings;
+use strict;
+
+package Prophet::Resolver::AlwaysTarget;
+use base qw/Prophet::Resolver/;
+
+
+sub run {
+ my $self = shift;
+ my $conflict = shift;
+ return 0 if $conflict->file_op_conflict;
+
+ my $resolution = Prophet::Change->new_from_conflict( $conflict );
+
+ 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;
+}
+
+1;
+
Modified: SVN-PropDB/lib/Prophet/Sync/Source.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Sync/Source.pm (original)
+++ SVN-PropDB/lib/Prophet/Sync/Source.pm Tue Apr 1 20:18:19 2008
@@ -53,6 +53,7 @@
my %args = validate( @_, { from => { isa => 'Prophet::Sync::Source' },
use_resdb => { optional => 1 },
resolver => { optional => 1 },
+ resolver_class => { optional => 1 },
conflict_callback => { optional => 1 } } );
my $source = $args{'from'};
@@ -67,7 +68,7 @@
next if ( $self->has_seen_changeset($changeset) );
next if $changeset->is_nullification || $changeset->is_resolution;
- $self->integrate_changeset( changeset => $changeset, conflict_callback => $args{conflict_callback}, resolver => $args{resolver}, resdb => $resdb);
+ $self->integrate_changeset( changeset => $changeset, conflict_callback => $args{conflict_callback}, resolver => $args{resolver}, resolver_class => $args{'resolver_class'}, resdb => $resdb);
}
}
@@ -77,6 +78,7 @@
my %args = validate( @_,
{ from => { isa => 'Prophet::Sync::Source' },
resolver => { optional => 1 },
+ resolver_class => { optional => 1 },
conflict_callback => { optional => 1 } } );
my $source = $args{'from'};
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 20:18:19 2008
@@ -4,6 +4,7 @@
package Prophet::Sync::Source::SVN;
use base qw/Prophet::Sync::Source/;
use Params::Validate qw(:all);
+use UNIVERSAL::require;
use SVN::Core;
use SVN::Ra;
@@ -231,6 +232,7 @@
my %args = validate( @_,
{ changeset => { isa => 'Prophet::ChangeSet' },
resolver => { optional => 1 },
+ resolver_class => { optional => 1 },
resdb => { optional => 1 },
conflict_callback => { optional => 1 }
}
@@ -258,6 +260,11 @@
if (my $conflict = $self->conflicts_from_changeset($changeset ) ) {
$args{conflict_callback}->($conflict) if $args{'conflict_callback'};
$conflict->resolvers([sub { $args{resolver}->(@_) }]) if $args{resolver};
+ if ($args{resolver_class} ) {
+ $args{resolver_class}->require|| die $@;
+ $conflict->resolvers([sub { $args{resolver_class}->run(@_); }])
+
+ }
my $resolutions = $conflict->generate_resolution($args{resdb});
#figure out our conflict resolution
@@ -309,37 +316,4 @@
}
-=head2 always_mine_resolver
-
-=cut
-
-sub always_mine_resolver {
- return
- sub { my $conflict = shift;
- return 0 if $conflict->file_op_conflict;
-
- my $resolution = Prophet::Change->new_from_conflict( $conflict );
-
- 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;
- };
-}
-
-
-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/t/real-conflicting-merge.t
==============================================================================
--- SVN-PropDB/t/real-conflicting-merge.t (original)
+++ SVN-PropDB/t/real-conflicting-merge.t Tue Apr 1 20:18:19 2008
@@ -66,11 +66,13 @@
);
} qr/my way of death/, 'our resolver is actually called';
+
ok_added_revisions( sub {
$target->import_changesets(
from => $source,
- resolver => $target->always_mine_resolver )
+ resolver_class => 'Prophet::Resolver::AlwaysTarget'
+ )
}, 3, '3 revisions since the merge' );
my @changesets = fetch_newest_changesets(3);
More information about the Bps-public-commit
mailing list