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

jesse jesse at bestpractical.com
Thu Feb 12 15:06:11 EST 2009


The branch, master has been updated
       via  d6a783d0e64569295f4d5dba8c0de12eb6b28bee (commit)
       via  8f70480249aa65214396f3559d9eb592da090d95 (commit)
      from  480c0dbb38c1302c4a8616c8a57b5ee97d6c1876 (commit)

Summary of changes:
 lib/Prophet/CLI.pm               |    7 ++++++-
 lib/Prophet/CLI/Command/Merge.pm |    3 +++
 lib/Prophet/ForeignReplica.pm    |    3 +++
 3 files changed, 12 insertions(+), 1 deletions(-)

- Log -----------------------------------------------------------------
commit 8f70480249aa65214396f3559d9eb592da090d95
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Thu Feb 12 14:50:11 2009 -0500

    Disable paging when doing password prompting

diff --git a/lib/Prophet/ForeignReplica.pm b/lib/Prophet/ForeignReplica.pm
index 6fd0126..dfbc479 100644
--- a/lib/Prophet/ForeignReplica.pm
+++ b/lib/Prophet/ForeignReplica.pm
@@ -69,6 +69,7 @@ sub prompt_for_login {
 
     my $password;
 
+    Prophet::CLI->end_pager();
     # XXX belongs to some CLI callback
     use Term::ReadKey;
     local $| = 1;
@@ -85,6 +86,7 @@ sub prompt_for_login {
     chomp $password;
     ReadMode 1;
     print "\n";
+    Prophet::CLI->start_pager();
     return ( $username, $password );
 }
 

commit d6a783d0e64569295f4d5dba8c0de12eb6b28bee
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Thu Feb 12 15:04:30 2009 -0500

    Be smarter about when we run the pager

diff --git a/lib/Prophet/CLI.pm b/lib/Prophet/CLI.pm
index 55cb6be..557cc38 100644
--- a/lib/Prophet/CLI.pm
+++ b/lib/Prophet/CLI.pm
@@ -184,8 +184,13 @@ sub start_pager {
     }
 }
 
+sub in_pager {
+    return $ORIGINAL_STDOUT ? 1 :0;
+}
+
 sub end_pager {
-    return unless ($ORIGINAL_STDOUT);
+    my $self = shift;
+    return unless ($self->in_pager);
     *STDOUT = $ORIGINAL_STDOUT ;
     close($pager);
     $ORIGINAL_STDOUT=undef;
diff --git a/lib/Prophet/CLI/Command/Merge.pm b/lib/Prophet/CLI/Command/Merge.pm
index bf202f3..c354ebf 100644
--- a/lib/Prophet/CLI/Command/Merge.pm
+++ b/lib/Prophet/CLI/Command/Merge.pm
@@ -10,6 +10,7 @@ __PACKAGE__->register_arg_translations( f => 'force' );
 sub run {
     my $self = shift;
 
+    Prophet::CLI->end_pager();
     $self->source( Prophet::Replica->get_handle(
         url       => $self->arg('from'),
         app_handle => $self->app_handle,
@@ -31,12 +32,14 @@ sub run {
 
     my $changesets = $self->_do_merge();
 
+    Prophet::CLI->start_pager();
     $self->print_report($changesets);
 }
 
 sub print_report {
     my $self = shift;
     my $changesets = shift;
+    print "\n";
     if ($changesets == 0) {
         print "No new changesets.\n";
     }
diff --git a/lib/Prophet/ForeignReplica.pm b/lib/Prophet/ForeignReplica.pm
index dfbc479..1f551e0 100644
--- a/lib/Prophet/ForeignReplica.pm
+++ b/lib/Prophet/ForeignReplica.pm
@@ -69,6 +69,7 @@ sub prompt_for_login {
 
     my $password;
 
+    my $was_in_pager = Prophet::CLI->in_pager();
     Prophet::CLI->end_pager();
     # XXX belongs to some CLI callback
     use Term::ReadKey;
@@ -86,7 +87,7 @@ sub prompt_for_login {
     chomp $password;
     ReadMode 1;
     print "\n";
-    Prophet::CLI->start_pager();
+    Prophet::CLI->start_pager() if ($was_in_pager);
     return ( $username, $password );
 }
 

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



More information about the Bps-public-commit mailing list