[Bps-public-commit] Prophet branch, master, updated. ca04ce26e7e8e48232686c0d98242cac83625071

clkao at bestpractical.com clkao at bestpractical.com
Wed Apr 15 03:18:10 EDT 2009


The branch, master has been updated
       via  ca04ce26e7e8e48232686c0d98242cac83625071 (commit)
      from  424407556dc5a47442c93c764b4f1b99be1bcb8e (commit)

Summary of changes:
 lib/Prophet/CLI/Command/Log.pm |    1 +
 lib/Prophet/Replica/prophet.pm |    5 ++++-
 lib/Prophet/Replica/sqlite.pm  |    5 ++++-
 3 files changed, 9 insertions(+), 2 deletions(-)

- Log -----------------------------------------------------------------
commit ca04ce26e7e8e48232686c0d98242cac83625071
Author: Chia-liang Kao <clkao at clkao.org>
Date:   Wed Apr 15 15:16:21 2009 +0800

    - provide reverse option to traverse_changeset.
    - use reverse by default for CLI::log.

diff --git a/lib/Prophet/CLI/Command/Log.pm b/lib/Prophet/CLI/Command/Log.pm
index ef1f22e..c08eefb 100644
--- a/lib/Prophet/CLI/Command/Log.pm
+++ b/lib/Prophet/CLI/Command/Log.pm
@@ -32,6 +32,7 @@ sub run {
     die "START must be before END in START..END.\n" if $end - $start < 0;
 
     $handle->traverse_changesets(
+        reverse  => 1,
         after    => $start - 1,
         until    => $end,
         callback => sub {
diff --git a/lib/Prophet/Replica/prophet.pm b/lib/Prophet/Replica/prophet.pm
index 6459090..d4f35d3 100644
--- a/lib/Prophet/Replica/prophet.pm
+++ b/lib/Prophet/Replica/prophet.pm
@@ -670,6 +670,7 @@ sub traverse_changesets {
         {   after    => 1,
             callback => 1,
             until    => 0,
+            reverse  => 0,
         }
     );
 
@@ -682,7 +683,9 @@ sub traverse_changesets {
 
     my $chgidx = $self->_read_changeset_index;
     $self->log_debug("Traversing changesets between $first_rev and $latest");
-    for my $rev ( $first_rev .. $latest ) {
+    my @range = ( $first_rev .. $latest );
+    @range = reverse @range if $args{reverse};
+    for my $rev ( @range ) {
         $self->log_debug("Fetching changeset $rev");
         my $changeset = $self->_get_changeset_index_entry(
             sequence_no => $rev,
diff --git a/lib/Prophet/Replica/sqlite.pm b/lib/Prophet/Replica/sqlite.pm
index 7793e24..cd2edf6 100644
--- a/lib/Prophet/Replica/sqlite.pm
+++ b/lib/Prophet/Replica/sqlite.pm
@@ -405,6 +405,7 @@ sub traverse_changesets {
         {   after    => 1,
             callback => 1,
             until    => 0,
+            reverse  => 0,
         }
     );
 
@@ -416,7 +417,9 @@ sub traverse_changesets {
     }
 
     $self->log_debug("Traversing changesets between $first_rev and $latest");
-    for my $rev ( $first_rev .. $latest ) {
+    my @range = ( $first_rev .. $latest );
+    @range = reverse @range if $args{reverse};
+    for my $rev ( @range ) {
         $self->log_debug("Fetching changeset $rev");
         my $changeset = $self->_load_changeset_from_db( sequence_no => $rev,);
         $args{callback}->($changeset);

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



More information about the Bps-public-commit mailing list