# # # patch "Monotone/AutomateStdio.pm" # from [ff026bb9fa40bc78faa3d847244061e13ae38423] # to [1dae1232ece3b6b544dfb92e9433ceae0d691e58] # # patch "Monotone/AutomateStdio.pod" # from [c01d7e34334d4b47e6a27fd63bff19d6bc07208d] # to [11d050f55c78b0c39a52b792c3e279a12e42e9fa] # # patch "mtn-tester" # from [68653c125f4059b91d4fe9bf2516d448d3383f2d] # to [c18eaecac2098aafe8f70660d778cdd0bfba71ba] # ============================================================ --- Monotone/AutomateStdio.pm ff026bb9fa40bc78faa3d847244061e13ae38423 +++ Monotone/AutomateStdio.pm 1dae1232ece3b6b544dfb92e9433ceae0d691e58 @@ -140,6 +140,7 @@ sub get_current_revision_id($\$); sub get_content_changed(address@hidden); sub get_corresponding_path($\$$$$); sub get_current_revision_id($\$); +sub get_db_name($); sub get_error_message($); sub get_file($\$$); sub get_file_of($\$$;$); @@ -156,7 +157,7 @@ sub parents(address@hidden); sub leaves($\@); sub new($;$); sub parents(address@hidden); -sub register_error_handler($$); +sub register_error_handler($;$$); sub roots($\@); sub select(address@hidden); sub tags($$;$); @@ -183,8 +184,9 @@ sub warning_handler_wrapper($); # class or the name of the class to be # created. # $db_name : The full path of the Monotone database. If -# not provided then the database associated -# with the current workspace is used. +# this is not provided then the database +# associated with the current workspace is +# used. # Return Value : A reference to the newly created object. # ############################################################################## @@ -2015,18 +2017,18 @@ sub toposort($\@@) # registered for. One of "error", "warning" or # "both". # $callback : A reference to the error handler routine. If -# this is undef then the existing error handler -# routine is unregistered and errors are raised -# in the default way. +# this is not provided then the existing error +# handler routine is unregistered and errors are +# handled in the default way. # ############################################################################## -sub register_error_handler($$) +sub register_error_handler($;$$) { - shift() if ($#_ > 1); + shift() if ($_[0] eq __PACKAGE__ || ref($_[0]) eq __PACKAGE__); my($severity, $handler) = @_; if ($severity eq "error") @@ -2077,6 +2079,31 @@ sub register_error_handler($$) # ############################################################################## # +# Routine - get_db_name +# +# Description - Return the the file name of the Monotone database as given +# to the constructor. +# +# Data - $this : The object. +# Return Value : The file name of the database as given to +# the constructor or undef if no database was +# given. +# +############################################################################## + + + +sub get_db_name($) +{ + + my Monotone::AutomateStdio $this = $_[0]; + + return $this->{db_name}; + +} +# +############################################################################## +# # Routine - get_error_message # # Description - Return the last error message received from the mtn @@ -2582,7 +2609,7 @@ sub error_handler_wrapper($) my $message = $_[0]; &$error_handler("error", $message); - die(); + croak(__PACKAGE__ . ": Fatal error."); } # ============================================================ --- Monotone/AutomateStdio.pod c01d7e34334d4b47e6a27fd63bff19d6bc07208d +++ Monotone/AutomateStdio.pod 11d050f55c78b0c39a52b792c3e279a12e42e9fa @@ -66,23 +66,22 @@ Creates a new Monotone::AutomateStdio ob =over 4 -=item Bregister_error_handler($severity, -$handler)> +=item Bregister_error_handler($severity[, +$handler])> Registers the handler specified as a subroutine reference in $handler for errors of a certain severity as specified by $severity. $severity can be one of "warning", "error" or "both". This is a class method rather than an object one -as errors can be raised when calling a constructor. If undef is passed in -$handler then error handling is reset to the default behaviour for that -severity level. +as errors can be raised when calling a constructor. If no handler is given then +the error handling is reset to the default behaviour for that severity level. The handler subroutine is given two arguments, the first one is a severity string that indicates the severity of the error being handled, either "warning" or "error", and the error message. Please note that if the severity is "error" then it is expected that croak or die will be called by the handler, if this is -not the case then the library will do it anyway upon return. If you really need -to trap errors and prevent program exit then use an eval block to protect -yourself in the calling code. +not the case then the library will call croak() upon return. If you need to +trap errors and prevent program exit then use an eval block to protect yourself +in the calling code. =back @@ -216,10 +215,15 @@ in the workspace. Get the revision that would be created if an unrestricted commit was done in the workspace. +=item B<$mtn-Eget_db_name()> + +Return the the file name of the Monotone database as given to the +constructor. If no such name was given then undef is returned. + =item B<$mtn-Eget_error_message()> Return the last error message received from the mtn subprocess. An empty string -is returned if there is nothing to report. +is returned if no error has occurred yet. =item B<$mtn-Eget_file(\$buffer, $file_id)> @@ -421,10 +425,11 @@ Monotone::AutomateStdio-Eregister_er Except for the constructor and the Monotone::AutomateStdio-Eregister_error_handler(), $mtn-Eclosedown(), -$mtn-Eget_error_message() and $mtn-Eget_pid() methods, all remaining -methods return a boolean success indicator, true for success or false for -failure (where true is 1 and false is undef). The constructor returns a newly -created object, $mtn-Eget_error_message() returns a string, +$mtn-Eget_db_name(), $mtn-Eget_error_message() and $mtn-Eget_pid() +methods, all remaining methods return a boolean success indicator, true for +success or false for failure (where true is 1 and false is undef). The +constructor returns a newly created object, $mtn-Eget_db_name() returns a +string or undef, $mtn-Eget_error_message() returns a string, $mtn-Eget_pid() returns an integer and Monotone::AutomateStdio-Eregister_error_handler() and $mtn-Eclosedown() do not return anything. ============================================================ --- mtn-tester 68653c125f4059b91d4fe9bf2516d448d3383f2d +++ mtn-tester c18eaecac2098aafe8f70660d778cdd0bfba71ba @@ -26,10 +26,10 @@ Monotone::AutomateStdio->register_error_ printf(STDERR "PROBLEM (%s): %s\n", $severity, $message); die() if ($severity eq "error"); }); -# Monotone::AutomateStdio::register_error_handler("both", undef); +# Monotone::AutomateStdio::register_error_handler("both"); $mtn = Monotone::AutomateStdio->new("/home/aecoope/perl/test.mtn"); -# $mtn = Monotone->new(); +# $mtn = Monotone::AutomateStdio->new(); if (0) { if (! $mtn->branches(address@hidden))