App-Gitc

 view release on metacpan or  search on metacpan

lib/App/Gitc/Reversible.pm  view on Meta::CPAN




sub to_undo (&) {
    my ($code) = @_;
    push our(@undo_stack), $code;
    return;
}


sub reversibly(&) {
    my ($code) = @_;

    local $SIG{INT} = sub { die "SIGINT\n" };
    local $SIG{TERM} = sub { die "SIGTERM\n" };
    local our(@undo_stack);  # to allow nested, reversible computations

    my $rc = eval { $code->() };
    if ( my $exception = $@ ) {
        our $failure_warning;
        warn $failure_warning if defined $failure_warning;



( run in 0.864 second using v1.01-cache-2.11-cpan-49f99fa48dc )