[Bps-public-commit] r11898 - in Prophet/trunk: .

jesse at bestpractical.com jesse at bestpractical.com
Fri Apr 25 16:03:38 EDT 2008


Author: jesse
Date: Fri Apr 25 16:03:37 2008
New Revision: 11898

Modified:
   Prophet/trunk/   (props changed)
   Prophet/trunk/lib/Prophet/CLI.pm
   Prophet/trunk/lib/Prophet/Record.pm
   Prophet/trunk/lib/Prophet/Test.pm

Log:
 r30131 at 68-247-193-139:  jesse | 2008-04-25 16:00:39 -0400
  do more to hook up validation


Modified: Prophet/trunk/lib/Prophet/CLI.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI.pm	(original)
+++ Prophet/trunk/lib/Prophet/CLI.pm	Fri Apr 25 16:03:37 2008
@@ -208,7 +208,7 @@
     my $self = shift;
 
     my $record = $self->_get_record;
-    $record->load( uuid => $self->uuid );
+    $record->load( uuid => $self->uuid ) || $self->fatal_error("I couldn't find that record");
     if ( $record->delete ) {
         print $record->type . " " . $record->uuid . " deleted.\n";
     } else {
@@ -286,7 +286,7 @@
 sub _do_merge {
     my ( $self, $source, $target ) = @_;
     if ( $target->uuid eq $source->uuid ) {
-        fatal_error( "You appear to be trying to merge two identical replicas. "
+        $self->fatal_error( "You appear to be trying to merge two identical replicas. "
                 . "Either you're trying to merge a replica to itself or "
                 . "someone did a bad job cloning your database" );
     }
@@ -296,7 +296,7 @@
     $opts->{'prefer'} ||= 'none';
 
     if ( !$target->can_write_changesets) {
-        fatal_error( $target->url . " does not accept changesets. Perhaps it's unwritable or something" );
+        $self->fatal_error( $target->url . " does not accept changesets. Perhaps it's unwritable or something" );
     }
 
     $target->import_changesets(
@@ -311,6 +311,7 @@
 }
 
 sub fatal_error {
+    my $self = shift;
     my $reason = shift;
     die $reason . "\n";
 

Modified: Prophet/trunk/lib/Prophet/Record.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Record.pm	(original)
+++ Prophet/trunk/lib/Prophet/Record.pm	Fri Apr 25 16:03:37 2008
@@ -170,8 +170,9 @@
     my %args = validate( @_, { props => 1 } );
 
     $self->canonicalize_props( $args{'props'} );
-    $self->validate_props( $args{'props'} );
+    $self->validate_props( $args{'props'} ) || return undef;
     $self->handle->set_record_props( type => $self->type, uuid => $self->uuid, props => $args{'props'} );
+    return 1;
 }
 
 =head2 get_props
@@ -228,12 +229,16 @@
     my $self   = shift;
     my $props  = shift;
     my $errors = {};
+    my @errors;
     for my $key ( uniq( keys %$props, $self->declared_props ) ) {
         return undef unless ( $self->_validate_prop_name($key) );
         if ( my $sub = $self->can( 'validate_prop_' . $key ) ) {
-            $sub->( $self, props => $props, errors => $errors ) or die "validation error on $key: $errors->{$key}\n";
+            $sub->( $self, props => $props, errors => $errors ) || push @errors, "Validation error for '$key': $errors->{$key}\n";
         }
     }
+    if (@errors) {
+        die join('', at errors);   
+    }
     return 1;
 }
 

Modified: Prophet/trunk/lib/Prophet/Test.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Test.pm	(original)
+++ Prophet/trunk/lib/Prophet/Test.pm	Fri Apr 25 16:03:37 2008
@@ -4,7 +4,7 @@
 package Prophet::Test;
 use base qw/Test::More Exporter/;
 our @EXPORT = qw/as_alice as_bob as_charlie as_david as_user run_ok repo_uri_for run_script run_output_matches replica_last_rev replica_merge_tickets replica_uuid_for fetch_newest_changesets ok_added_revisions replica_uuid
-    serialize_conflict serialize_changeset in_gladiator diag
+    serialize_conflict serialize_changeset in_gladiator diag is_script_output
     /;
 
 use File::Path 'rmtree';



More information about the Bps-public-commit mailing list