[Bps-public-commit] Prophet - A disconnected, replicated p2p database branch, master, updated. bb5d46b3fbae7db5b34b15d2961a7bb7f4dbc958

spang at bestpractical.com spang at bestpractical.com
Tue Jan 20 13:45:19 EST 2009


The branch, master has been updated
       via  bb5d46b3fbae7db5b34b15d2961a7bb7f4dbc958 (commit)
       via  e15b37ee869fa4d40555d358e7930c1acee64f17 (commit)
      from  639940085110f915a9f3648148f9b315177ac24d (commit)

Summary of changes:
 lib/Prophet/CLI/Command/Update.pm    |   27 +++++++++++++++++++--------
 lib/Prophet/CLI/TextEditorCommand.pm |    4 ++--
 2 files changed, 21 insertions(+), 10 deletions(-)

- Log -----------------------------------------------------------------
commit e15b37ee869fa4d40555d358e7930c1acee64f17
Author: Christine Spang <spang at bestpractical.com>
Date:   Tue Jan 20 12:35:19 2009 +0200

    newline fail

diff --git a/lib/Prophet/CLI/TextEditorCommand.pm b/lib/Prophet/CLI/TextEditorCommand.pm
index c31b5df..7a55534 100644
--- a/lib/Prophet/CLI/TextEditorCommand.pm
+++ b/lib/Prophet/CLI/TextEditorCommand.pm
@@ -106,9 +106,9 @@ sub handle_template_errors {
 
     ${ $args{'template_ref'} }
         = "$errors_pattern\n\n"
-        . $args{error} . "\n\n\n"
+        . $args{error} . "\n\n"
         . 'You can bypass validation for a property by appending a ! to it.'
-        . "\n\n" . $args{bad_template};
+        . "\n\n\n" . $args{bad_template};
     return 0;
 }
 

commit bb5d46b3fbae7db5b34b15d2961a7bb7f4dbc958
Author: Christine Spang <spang at bestpractical.com>
Date:   Tue Jan 20 20:40:04 2009 +0200

    don't update properties if they haven't changed

diff --git a/lib/Prophet/CLI/Command/Update.pm b/lib/Prophet/CLI/Command/Update.pm
index 6443820..cf1b628 100644
--- a/lib/Prophet/CLI/Command/Update.pm
+++ b/lib/Prophet/CLI/Command/Update.pm
@@ -30,17 +30,28 @@ sub run {
     my $record = $self->_load_record;
 
     my $new_props = $self->edit_record($record);
-    my $result = $record->set_props( props => $new_props );
 
-    if ($result) {
-        print $record->type . " " . $record->luid . " (".$record->uuid.")"." updated.\n";
+    # filter out props that haven't changed
+    for my $prop (keys %$new_props) {
+        delete $new_props->{$prop}
+            if ($record->prop($prop) eq $new_props->{$prop});
+    }
+
+    if (keys %$new_props) {
+        my $result = $record->set_props( props => $new_props );
+
+        if ($result) {
+            print $record->type . " " . $record->luid . " (".$record->uuid.")"." updated.\n";
 
+        } else {
+            print "SOMETHING BAD HAPPENED "
+                . $record->type . " "
+                . $record->luid . " ("
+                . $record->uuid
+                . ") not updated.\n";
+        }
     } else {
-        print "SOMETHING BAD HAPPENED "
-            . $record->type . " "
-            . $record->luid . " ("
-            . $record->uuid
-            . ") not updated.\n";
+        print "No properties changed.\n";
     }
 }
 

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list