[Bps-public-commit] r15062 - in Prophet/trunk: . lib/Prophet/CLI/Command lib/Prophet/Replica

sartak at bestpractical.com sartak at bestpractical.com
Tue Aug 12 08:06:08 EDT 2008


Author: sartak
Date: Tue Aug 12 08:06:07 2008
New Revision: 15062

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

Log:
 r69371 at onn:  sartak | 2008-08-12 08:00:50 -0400
 Localize $SIG{__DIE__} to DEFAULT so exceptions just escape the eval instead of running arbitrary code


Modified: Prophet/trunk/lib/Prophet/App.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/App.pm	(original)
+++ Prophet/trunk/lib/Prophet/App.pm	Tue Aug 12 08:06:07 2008
@@ -104,7 +104,11 @@
 
     $file =~ s/::/\//g;
 
-    my $retval = eval  {CORE::require "$file"} ;
+    my $retval = eval {
+        local $SIG{__DIE__} = 'DEFAULT';
+        CORE::require "$file"
+    };
+
     my $error = $@;
     if (my $message = $error) {
         $message =~ s/ at .*?\n$//;

Modified: Prophet/trunk/lib/Prophet/CLI.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI.pm	(original)
+++ Prophet/trunk/lib/Prophet/CLI.pm	Tue Aug 12 08:06:07 2008
@@ -445,7 +445,10 @@
 
     local *ARGV = \@args;
     $ofh = select $output if $output;
-    my $ret = eval { $self->run_one_command };
+    my $ret = eval {
+        local $SIG{__DIE__} = 'DEFAULT';
+        $self->run_one_command
+    };
     warn $@ if $@;
     select $ofh if $ofh;
     return $ret;

Modified: Prophet/trunk/lib/Prophet/CLI/Command/Shell.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI/Command/Shell.pm	(original)
+++ Prophet/trunk/lib/Prophet/CLI/Command/Shell.pm	Tue Aug 12 08:06:07 2008
@@ -35,7 +35,10 @@
     while (defined(local $_ = $self->readline($self->prompt))) {
         next if /^\s*$/;
         local @ARGV = split ' ', $_;
-        eval { $self->run_one_command };
+        eval {
+            local $SIG{__DIE__} = 'DEFAULT';
+            $self->run_one_command;
+        };
         warn $@ if $@;
     }
 }

Modified: Prophet/trunk/lib/Prophet/Replica.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Replica.pm	(original)
+++ Prophet/trunk/lib/Prophet/Replica.pm	Tue Aug 12 08:06:07 2008
@@ -763,6 +763,7 @@
     my ($changeset) = validate_pos(@_, { isa => 'Prophet::ChangeSet'});
     $self->_unimplemented ('record_changes') unless ($self->can_write_changesets);
     eval {
+        local $SIG{__DIE__} = 'DEFAULT';
         my $inside_edit = $self->current_edit ? 1 : 0;
         $self->begin_edit(source => $changeset) unless ($inside_edit);
         $self->integrate_changes($changeset);

Modified: Prophet/trunk/lib/Prophet/Replica/Native.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Replica/Native.pm	(original)
+++ Prophet/trunk/lib/Prophet/Replica/Native.pm	Tue Aug 12 08:06:07 2008
@@ -125,6 +125,7 @@
     my $error;
     for my $url ($self->{url}, @{ $self->{_alt_urls} }) {
         my $new_self = eval {
+            local $SIG{__DIE__} = 'DEFAULT';
             my $obj = $self->new(%$args, url => $url, _alt_urls => []);
             $obj->_probe_or_create_db;
             $obj;
@@ -662,7 +663,10 @@
     my $self = shift;
     my ($file) = validate_pos( @_, 1 );
     if ( $self->fs_root ) {
-        return eval { $self->_slurp (file( $self->fs_root => $file )) };
+        return eval {
+            local $SIG{__DIE__} = 'DEFAULT';
+            $self->_slurp (file( $self->fs_root => $file ))
+        };
     } else {    # http replica
         return LWP::Simple::get( $self->url . "/" . $file );
     }

Modified: Prophet/trunk/lib/Prophet/Replica/SVN.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Replica/SVN.pm	(original)
+++ Prophet/trunk/lib/Prophet/Replica/SVN.pm	Tue Aug 12 08:06:07 2008
@@ -74,7 +74,10 @@
     $self->fs_root( $args{'repository'} );
     $self->set_db_uuid( $args{'db_uuid'} ) if ( $args{'db_uuid'} );
     
-    my $repos = eval { SVN::Repos::open( $self->fs_root ); };
+    my $repos = eval {
+        local $SIG{__DIE__} = 'DEFAULT';
+        SVN::Repos::open( $self->fs_root );
+    };
     # If we couldn't open the repository handle, we should create it
     if ( $@ && !-d $self->fs_root ) {
         $repos = SVN::Repos::create( $self->fs_root, undef, undef, undef, undef, $self->_pool );
@@ -341,7 +344,10 @@
 
     my $file = $self->_file_for( uuid => $args{uuid}, type => $args{type} );
     foreach my $prop ( keys %{ $args{'props'} } ) {
-        eval { $self->current_edit->root->change_node_prop( $file, $prop, $args{'props'}->{$prop}, undef ) };
+        eval {
+            local $SIG{__DIE__} = 'DEFAULT';
+            $self->current_edit->root->change_node_prop( $file, $prop, $args{'props'}->{$prop}, undef )
+        };
         Carp::confess($@) if ($@);
     }
 }



More information about the Bps-public-commit mailing list