[Bps-public-commit] r15203 - in Prophet/trunk/lib/Prophet: CLI/Command

jesse at bestpractical.com jesse at bestpractical.com
Sun Aug 17 21:49:16 EDT 2008


Author: jesse
Date: Sun Aug 17 21:49:15 2008
New Revision: 15203

Added:
   Prophet/trunk/lib/Prophet/CLI/Command/Log.pm
Modified:
   Prophet/trunk/lib/Prophet/ChangeSet.pm

Log:
* Added a first pass at a 'log' action'

Added: Prophet/trunk/lib/Prophet/CLI/Command/Log.pm
==============================================================================
--- (empty file)
+++ Prophet/trunk/lib/Prophet/CLI/Command/Log.pm	Sun Aug 17 21:49:15 2008
@@ -0,0 +1,27 @@
+package Prophet::CLI::Command::Log;
+use Moose;
+extends 'Prophet::CLI::Command';
+
+sub run {
+    my $self = shift;
+    my $handle = $self->handle;
+    my $newest = $self->arg('last') || $handle->latest_sequence_no;
+    my $start = $newest - ($self->arg('count') || '20');
+    $start = 0 if $start < 0;
+
+    $handle->traverse_changesets(
+        after    => $start,
+        callback => sub {
+            my $changeset = shift;
+          print $changeset->as_string(change_header => sub {
+                    my $change = shift;
+                    return " # " . $change->record_type. " ".$self->app_handle->handle->find_or_create_luid(uuid => $change->record_uuid)." (" . $change->record_uuid.")\n";
+                       
+              });
+        },
+    );
+
+
+}
+
+1;

Modified: Prophet/trunk/lib/Prophet/ChangeSet.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/ChangeSet.pm	(original)
+++ Prophet/trunk/lib/Prophet/ChangeSet.pm	Sun Aug 17 21:49:15 2008
@@ -164,18 +164,19 @@
     my $self = shift;
     my %args = validate(@_, {
         change_filter => 0,
+        change_header => 0,
     });
 
     my $change_filter = $args{change_filter};
 
     my $out = '';
 
-    $out .= sprintf "Changeset %d@%s\n",
+    $out .= sprintf "Change %d by %s at %s\n\t\t\t\t\(%d@%s)\n\n",
+            $self->sequence_no,
+                ($self->creator || '(unknown)'),
+                $self->created,
                 $self->original_sequence_no,
                 $self->original_source_uuid;
-    $out .= sprintf "by %s at %s\n",
-                ($self->creator || '(unknown)'),
-                $self->created;
 
     for my $change ($self->changes) {
         my @prop_changes = $change->prop_changes;
@@ -185,6 +186,10 @@
             next unless $change_filter->($change);
         }
 
+        if ($args{change_header}) {
+          $out .=   $args{change_header}->($change);
+        }
+
         for my $prop_change (@prop_changes) {
             $out .= "  " . $prop_change->summary . "\n";
         }



More information about the Bps-public-commit mailing list