# # # patch "lib/Monotone/AutomateStdio.pm" # from [2403487abd1909b362770c74170b7d5ce0a7a335] # to [66387d46675f90192b46be48463da98141aaaf0c] # # patch "lib/Monotone/AutomateStdio.pod" # from [75d286ae2ddd65865d03fff4679042426839de66] # to [ef96fc38d801420129df64b1cbf74ad1201017d7] # # patch "mtn-tester" # from [35ac607bd77a3fe50bbb90b3e4cd7906d82464f7] # to [0a8a9e08d4ffa74b173908eb1ea56af351f4daea] # ============================================================ --- lib/Monotone/AutomateStdio.pm 2403487abd1909b362770c74170b7d5ce0a7a335 +++ lib/Monotone/AutomateStdio.pm 66387d46675f90192b46be48463da98141aaaf0c @@ -2,7 +2,7 @@ # # File Name - AutomateStdio.pm # -# Description - Class module that provides an interface to Monotone's +# Description - A class module that provides an interface to Monotone's # automate stdio interface. # # Authors - A.E.Cooper. With contributions from T.Keller. @@ -84,11 +84,13 @@ use constant MTN_LUA use constant MTN_INVENTORY_TAKING_OPTIONS => 10; use constant MTN_INVENTORY_WITH_BIRTH_ID => 11; use constant MTN_LUA => 12; -use constant MTN_P_SELECTOR => 13; -use constant MTN_READ_PACKETS => 14; -use constant MTN_SET_ATTRIBUTE => 15; -use constant MTN_SET_DB_VARIABLE => 16; -use constant MTN_SHOW_CONFLICTS => 17; +use constant MTN_M_SELECTOR => 13; +use constant MTN_P_SELECTOR => 14; +use constant MTN_READ_PACKETS => 15; +use constant MTN_SET_ATTRIBUTE => 16; +use constant MTN_SET_DB_VARIABLE => 17; +use constant MTN_SHOW_CONFLICTS => 18; +use constant MTN_U_SELECTOR => 19; # Constants used to represent the different error levels. @@ -219,6 +221,13 @@ my($db_locked_handler_data, # ***** FUNCTIONAL PROTOTYPES ***** +# Constructors and destructor. + +sub new_from_db($;$$); +sub new_from_ws($;$$); +*new = *new_from_db; +sub DESTROY($); + # Public methods. sub ancestors($$@); @@ -264,8 +273,6 @@ sub lua($$$;@); sub keys($$); sub leaves($$); sub lua($$$;@); -sub new_from_db($;$$); -sub new_from_ws($;$$); sub packet_for_fdata($$$); sub packet_for_fdelta($$$$); sub packet_for_rdata($$$); @@ -290,7 +297,6 @@ sub toposort($$@); # Public aliased methods. *attributes = *get_attributes; -*new = *new_from_db; *db_set = *set_db_variable; # Private methods and routines. @@ -329,11 +335,13 @@ our %EXPORT_TAGS = (capabilities => [qw( MTN_INVENTORY_TAKING_OPTIONS MTN_INVENTORY_WITH_BIRTH_ID MTN_LUA + MTN_M_SELECTOR MTN_P_SELECTOR MTN_READ_PACKETS MTN_SET_ATTRIBUTE MTN_SET_DB_VARIABLE - MTN_SHOW_CONFLICTS)], + MTN_SHOW_CONFLICTS + MTN_U_SELECTOR)], severities => [qw(MTN_SEVERITY_ALL MTN_SEVERITY_ERROR MTN_SEVERITY_WARNING)]); @@ -470,13 +478,13 @@ sub new_from_ws($;$$) # # Description - Class destructor. # -# Data - None. +# Data - $this : The object. # ############################################################################## -sub DESTROY +sub DESTROY($) { my $this = $_[0]; @@ -2828,6 +2836,16 @@ sub supports($$) return 1 if ($this->{mtn_aif_major} >= 9); } + elsif ($feature == MTN_M_SELECTOR || $feature == MTN_U_SELECTOR) + { + + # These are only available from version 0.43 (i/f version 9.x). + + return 1 if ($this->{mtn_aif_major} >= 10 + || ($this->{mtn_aif_major} == 9 + && $this->{mtn_version} eq "0.43")); + + } else { @@ -3127,14 +3145,17 @@ sub register_db_locked_handler(;$$$) { my $this; - if (ref($_[0]) eq __PACKAGE__) + if ($_[0]->isa(__PACKAGE__)) { - $this = shift(); + if (ref($_[0]) ne "") + { + $this = shift(); + } + else + { + shift(); + } } - elsif ($_[0] eq __PACKAGE__) - { - shift(); - } my($handler, $client_data) = @_; if (defined($this)) @@ -3192,7 +3213,7 @@ sub register_error_handler($;$$$) sub register_error_handler($;$$$) { - shift() if ($_[0] eq __PACKAGE__ || ref($_[0]) eq __PACKAGE__); + shift() if ($_[0]->isa(__PACKAGE__)); my($severity, $handler, $client_data) = @_; if ($severity == MTN_SEVERITY_ERROR) @@ -3278,14 +3299,17 @@ sub register_io_wait_handler(;$$$$) { my $this; - if (ref($_[0]) eq __PACKAGE__) + if ($_[0]->isa(__PACKAGE__)) { - $this = shift(); + if (ref($_[0]) ne "") + { + $this = shift(); + } + else + { + shift(); + } } - elsif ($_[0] eq __PACKAGE__) - { - shift(); - } my($handler, $timeout, $client_data) = @_; if (defined($timeout)) @@ -3357,14 +3381,17 @@ sub switch_to_ws_root($$) { my $this; - if (ref($_[0]) eq __PACKAGE__) + if ($_[0]->isa(__PACKAGE__)) { - $this = shift(); + if (ref($_[0]) ne "") + { + $this = shift(); + } + else + { + shift(); + } } - elsif ($_[0] eq __PACKAGE__) - { - shift(); - } my $switch = $_[0]; if (defined($this)) @@ -4093,6 +4120,26 @@ sub startup($) ($this->{mtn_aif_major}, $this->{mtn_aif_minor}) = ($version =~ m/^(\d+)\.(\d+)$/); + # If necessary get the version of the actual application (sometimes + # needed to differentiate when certain features were introduced that do + # not affect the automate stdio interface version. + + if ($this->{mtn_aif_major} == 9) + { + my($file, + $line); + &$croaker("Could not run command `mtn --version'") + unless (defined($file = IO::File->new("mtn --version |"))); + while (defined($line = $file->getline())) + { + if ($line =~ m/^monotone (\d+\.\d*) ./) + { + $this->{mtn_version} = $1; + } + } + $file->close(); + } + } } @@ -4273,6 +4320,7 @@ sub create_object_data() honour_suspend_certs => 1, mtn_aif_major => 0, mtn_aif_minor => 0, + mtn_version => undef, cmd_cnt => 0, db_is_locked => undef, db_locked_handler => undef, ============================================================ --- lib/Monotone/AutomateStdio.pod 75d286ae2ddd65865d03fff4679042426839de66 +++ lib/Monotone/AutomateStdio.pod ef96fc38d801420129df64b1cbf74ad1201017d7 @@ -822,11 +822,13 @@ that is currently being used by this obj MTN_INVENTORY_TAKING_OPTIONS MTN_INVENTORY_WITH_BIRTH_ID MTN_LUA + MTN_M_SELECTOR MTN_P_SELECTOR MTN_READ_PACKETS MTN_SET_ATTRIBUTE MTN_SET_DB_VARIABLE MTN_SHOW_CONFLICTS + MTN_U_SELECTOR In order to get these constants into your namespace you need to use the following to load in this library. @@ -1007,7 +1009,7 @@ opinions on this then please let me know to have a thread do that for you rather than use signals. If you have different opinions on this then please let me know. -==head2 General +=head2 General When the output of a command from the automate stdio interface changes dramatically, it will probably not be possible to protect Perl applications ============================================================ --- mtn-tester 35ac607bd77a3fe50bbb90b3e4cd7906d82464f7 +++ mtn-tester 0a8a9e08d4ffa74b173908eb1ea56af351f4daea @@ -229,7 +229,7 @@ my @test_list = system("mtn add NEW.txt"); }, posc => sub { - system("mtn revert ."); + system("mtn --quiet revert ."); system("rm NEW.txt"); }, type => RECORD_LIST, @@ -246,7 +246,7 @@ my @test_list = system("mtn add NEW.txt"); }, posc => sub { - system("mtn revert ."); + system("mtn --quiet revert ."); system("rm NEW.txt"); }, type => RECORD_LIST, @@ -264,7 +264,7 @@ my @test_list = system("mtn add NEW.txt"); }, posc => sub { - system("mtn revert ."); + system("mtn --quiet revert ."); system("rm NEW.txt"); }, type => RECORD_LIST, @@ -282,7 +282,7 @@ my @test_list = system("mtn add NEW.txt"); }, posc => sub { - system("mtn revert ."); + system("mtn --quiet revert ."); system("rm NEW.txt"); }, type => RECORD_LIST, @@ -299,7 +299,7 @@ my @test_list = system("mtn add NEW.txt"); }, posc => sub { - system("mtn revert ."); + system("mtn --quiet revert ."); system("rm NEW.txt"); }, type => RECORD_LIST, @@ -401,20 +401,20 @@ my @test_list = {fn => \&Monotone::AutomateStdio::inventory, desc => "inventory (depth option)", - feat => MTN_INVENTORY_TAKE_OPTIONS, + feat => MTN_INVENTORY_TAKING_OPTIONS, type => RECORD_LIST, args => [["depth" => 1]]}, {fn => \&Monotone::AutomateStdio::inventory, desc => "inventory (depth + exclude play.cc options)", - feat => MTN_INVENTORY_TAKE_OPTIONS, + feat => MTN_INVENTORY_TAKING_OPTIONS, type => RECORD_LIST, args => [["depth" => 1, "exclude" => "play.cc"]]}, {fn => \&Monotone::AutomateStdio::inventory, desc => "inventory (most options)", - feat => MTN_INVENTORY_TAKE_OPTIONS, + feat => MTN_INVENTORY_TAKING_OPTIONS, type => RECORD_LIST, args => [["depth" => 1, "exclude" => "play.cc", @@ -424,7 +424,7 @@ my @test_list = {fn => \&Monotone::AutomateStdio::inventory, desc => "inventory (all options generates nothing)", - feat => MTN_INVENTORY_TAKE_OPTIONS, + feat => MTN_INVENTORY_TAKING_OPTIONS, type => RECORD_LIST, args => [["depth" => 1, "exclude" => "play.cc", @@ -436,7 +436,7 @@ my @test_list = {fn => \&Monotone::AutomateStdio::inventory, desc => "inventory (just changed unknown files)", - feat => MTN_INVENTORY_TAKE_OPTIONS, + feat => MTN_INVENTORY_TAKING_OPTIONS, type => RECORD_LIST, args => [["no-unchanged"]], prec => sub { @@ -449,7 +449,7 @@ my @test_list = {fn => \&Monotone::AutomateStdio::inventory, desc => "inventory (restrict output to those files under unix)", - feat => MTN_INVENTORY_TAKE_OPTIONS, + feat => MTN_INVENTORY_TAKING_OPTIONS, type => RECORD_LIST, args => [[], "unix"]}, @@ -658,7 +658,7 @@ $data = undef; $mtn = Monotone::AutomateStdio->new(["--key" => $key_id]); $data = undef; -if ($mtn->can(MTN_DB_GET)) +if ($mtn->supports(MTN_DB_GET)) { $data = undef if (! $mtn->db_get(\$data, "database", "default-server")); } @@ -695,7 +695,7 @@ foreach my $test (@test_list) foreach my $test (@test_list) { - if (! exists($test->{feat}) || $mtn->can($test->{feat})) + if (! exists($test->{feat}) || $mtn->supports($test->{feat})) { printf(" ========== %s ==========\n", $test->{desc}); if (exists($test->{prec}))