[Bps-public-commit] r11836 - in Prophet/trunk: . lib/Prophet/Replica

jesse at bestpractical.com jesse at bestpractical.com
Tue Apr 22 20:34:40 EDT 2008


Author: jesse
Date: Tue Apr 22 20:34:36 2008
New Revision: 11836

Modified:
   Prophet/trunk/   (props changed)
   Prophet/trunk/lib/Prophet/CLI.pm
   Prophet/trunk/lib/Prophet/Replica.pm
   Prophet/trunk/lib/Prophet/Replica/Native.pm
   Prophet/trunk/lib/Prophet/Replica/SVN.pm

Log:
 r29981 at 31b:  jesse | 2008-04-22 19:03:10 -0400
 * clean up a bit


Modified: Prophet/trunk/lib/Prophet/CLI.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI.pm	(original)
+++ Prophet/trunk/lib/Prophet/CLI.pm	Tue Apr 22 20:34:36 2008
@@ -163,13 +163,11 @@
 sub do_search {
     my $self = shift;
 
-    my $regex;
-    unless ( $regex = $self->args->{regex} ) {
-        die "Specify a regular expression and we'll search for records matching that regex";
-    }
     my $record = $self->_get_record;
     $record->collection_class->require;
     my $records = $record->collection_class->new( handle => $self->app_handle->handle, type => $self->type );
+
+    if (my  $regex = $self->args->{regex} ) {
     $records->matching(
         sub {
             my $item  = shift;
@@ -178,7 +176,9 @@
             return 0;
         }
     );
-
+    } else {
+        $records->matching( sub {1});
+    }
     for ( sort { $a->uuid cmp $b->uuid } @{ $records->as_array_ref } ) {
         if($_->summary_props) {
         print $_->format_summary . "\n";
@@ -194,8 +194,14 @@
 
     my $record = $self->_get_record;
     $record->load( uuid => $self->uuid );
-    $record->set_props( props => $self->args );
+    my $result=    $record->set_props( props => $self->args );
+    if ($result ){
+        print $record->type . " " . $record->uuid . " updated.\n";
 
+    } else {
+        print "SOMETHING BAD HAPPENED ".$record->type . " " . $record->uuid . " not updated.\n";
+
+    }
 }
 
 sub do_delete {
@@ -215,7 +221,11 @@
     my $self = shift;
 
     my $record = $self->_get_record;
-    $record->load( uuid => $self->uuid );
+    if(!  $record->load( uuid => $self->uuid ) ) {
+        print "Record not found\n";
+        return;
+    }
+    
     print "id: " . $record->uuid . "\n";
     my $props = $record->get_props();
     for ( keys %$props ) {

Modified: Prophet/trunk/lib/Prophet/Replica.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Replica.pm	(original)
+++ Prophet/trunk/lib/Prophet/Replica.pm	Tue Apr 22 20:34:36 2008
@@ -552,8 +552,6 @@
 Called ONLY on local resolution creation. (Synced resolutions are just synced as records)
 
 =cut
-
-
 sub _record_resolution {
     my $self      = shift;
     my ($change) = validate_pos(@_, { isa => 'Prophet::Change'});
@@ -572,7 +570,6 @@
         }
     );
 }
-
 =head1 Routines dealing with integrating changesets into a replica
 
 =head2 record_changes Prophet::ChangeSet
@@ -581,7 +578,6 @@
 and then call the _after_record_changes() hook
 
 =cut
-
 sub record_changes {
     my $self      = shift;
     my ($changeset) = validate_pos(@_, { isa => 'Prophet::ChangeSet'});
@@ -595,7 +591,6 @@
     };
     die($@) if ($@);
 }
-
 sub _integrate_change {
     my $self   = shift;
     my ($change) = validate_pos(@_, { isa => 'Prophet::Change'});
@@ -633,8 +628,6 @@
     return $self->_record_metadata_for( $MERGETICKET_METATYPE, $changeset->original_source_uuid, 'last-changeset', $changeset->original_sequence_no );
 
 }
-
-
 =head1 metadata storage routines 
 
 =cut 
@@ -657,7 +650,6 @@
 
     };
 }
-
 sub _retrieve_metadata_for {
     my $self = shift;
     my ( $name, $source_uuid, $prop_name ) = validate_pos( @_, 1, 1, 1 );
@@ -670,7 +662,6 @@
     return $entry->prop($prop_name);
 
 }
-
 sub _record_metadata_for {
     my $self = shift;
     my ( $name, $source_uuid, $prop_name, $content )
@@ -692,8 +683,6 @@
         );
     }
 }
-
-
 =head1 The following functions need to be implemented by any Prophet backing store.
 
 =head2 uuid

Modified: Prophet/trunk/lib/Prophet/Replica/Native.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Replica/Native.pm	(original)
+++ Prophet/trunk/lib/Prophet/Replica/Native.pm	Tue Apr 22 20:34:36 2008
@@ -599,7 +599,7 @@
     $self->current_edit->add_change( change => $change );
 
     $self->commit_edit() unless ($inside_edit);
-
+    return 1;
 }
 
 sub get_record_props {
@@ -614,6 +614,7 @@
 sub record_exists {
     my $self = shift;
     my %args = validate( @_, { uuid => 1, type => 1 } );
+    return undef unless $args{'uuid'};
     return $self->_file_exists(
         $self->_record_index_filename(
             type => $args{'type'},

Modified: Prophet/trunk/lib/Prophet/Replica/SVN.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Replica/SVN.pm	(original)
+++ Prophet/trunk/lib/Prophet/Replica/SVN.pm	Tue Apr 22 20:34:36 2008
@@ -327,7 +327,7 @@
         type  => $args{'type'}
     );
     $self->commit_edit() unless ($inside_edit);
-
+    return 1;
 }
 
 sub _set_record_props {



More information about the Bps-public-commit mailing list