[Bps-public-commit] r11351 - in SVN-PropDB: . lib/Prophet/Resolver

jesse at bestpractical.com jesse at bestpractical.com
Tue Apr 1 20:46:43 EDT 2008


Author: jesse
Date: Tue Apr  1 20:46:31 2008
New Revision: 11351

Added:
   SVN-PropDB/lib/Prophet/Resolver/Prompt.pm
Modified:
   SVN-PropDB/   (props changed)
   SVN-PropDB/lib/Prophet/Conflict.pm
   SVN-PropDB/lib/Prophet/Resolver/AlwaysTarget.pm

Log:
 r28924 at 70-5-79-205:  jesse | 2008-04-01 14:46:06 -1000
 * Added a "Prompt" resolver. and change AlwaysTarget.pm to be less insane


Modified: SVN-PropDB/lib/Prophet/Conflict.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Conflict.pm	(original)
+++ SVN-PropDB/lib/Prophet/Conflict.pm	Tue Apr  1 20:46:31 2008
@@ -108,14 +108,14 @@
 
 sub attempt_automatic_conflict_resolution {
     my $self = shift;
-    my $conflict = shift;
+    my ($conflicting_change) = validate_pos(@_, { isa => 'Prophet::ConflictingChange'});
   # for everything from the changeset that is the same as the old value of the target replica
     # we can skip applying 
-    return 0 if $conflict->file_op_conflict;
+    return 0 if $conflicting_change->file_op_conflict;
 
-    my $resolution = Prophet::Change->new_from_conflict( $conflict );
+    my $resolution = Prophet::Change->new_from_conflict( $conflicting_change );
 
-    for my $prop_change ( @{$conflict->prop_conflicts} ) {
+    for my $prop_change ( @{$conflicting_change->prop_conflicts} ) {
         return 0 unless $prop_change->target_value eq $prop_change->source_new_value
     }
 

Modified: SVN-PropDB/lib/Prophet/Resolver/AlwaysTarget.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Resolver/AlwaysTarget.pm	(original)
+++ SVN-PropDB/lib/Prophet/Resolver/AlwaysTarget.pm	Tue Apr  1 20:46:31 2008
@@ -15,7 +15,7 @@
             for my $prop_conflict ( @{ $conflict->prop_conflicts } ) {
                 $resolution->add_prop_change(
                     name => $prop_conflict->name,
-                    old  => $prop_conflict->source_old_value,
+                    old  => $prop_conflict->source_new_value,
                     new  => $prop_conflict->target_value
                 );
             }

Added: SVN-PropDB/lib/Prophet/Resolver/Prompt.pm
==============================================================================
--- (empty file)
+++ SVN-PropDB/lib/Prophet/Resolver/Prompt.pm	Tue Apr  1 20:46:31 2008
@@ -0,0 +1,61 @@
+use warnings;
+use strict;
+
+package Prophet::Resolver::Prompt;
+use base qw/Prophet::Resolver/;
+
+
+sub  run {
+    my $self = shift;
+ my $conflicting_change = shift;
+            return 0 if $conflicting_change->file_op_conflict;
+
+            my $resolution = Prophet::Change->new_from_conflict( $conflicting_change );
+                    print "Oh no! There's a conflict between this replica and the one you're syncing from:\n";
+                    print $conflicting_change->node_type . " ".$conflicting_change->node_uuid."\n";
+
+            for my $prop_conflict ( @{ $conflicting_change->prop_conflicts } ) {
+
+                print $prop_conflict->name.": "\n;
+                print "(T)ARGET     ".$prop_conflicts->target_value ."\n";
+                print "SOURCE (O)LD ".$prop_conflicts->source_old_value ."\n";
+                print "SOURCE (N)EW ".$prop_conflicts->source_new_value ."\n";
+   
+
+              
+              while (my $choice = lc(substr(<STDIN> || 'T', 0, 1))) {
+                
+                if ($choice eq 't') {
+              
+
+                $resolution->add_prop_change(
+                    name => $prop_conflict->name,
+                    old  => $prop_conflict->source_new_value,
+                    new  => $prop_conflict->target_value
+                );
+                    last;
+                } elsif ($choice eq 'o') {
+
+                $resolution->add_prop_change(
+                    name => $prop_conflict->name,
+                    old  => $prop_conflict->source_new_value,
+                    new  => $prop_conflict->source_old_value
+                );
+                    last;
+
+                } elsif ($choice eq 'n') {
+                    last;
+                );
+
+
+                }
+                 else {
+                     print "(T), (O) or (N)? ";
+                     }
+            }
+            }
+            return $resolution;
+}
+
+1;
+



More information about the Bps-public-commit mailing list