monotone

monotone Commit Details

Date:2010-05-07 22:36:31 (9 years 14 days ago)
Author:Tony Cooper
Branch:net.venge.monotone.contrib.lib.automate-stdio
Commit:696ccc76fe8b761defb874ebc2252bd4b78ab03f
Parents: 012c191853bf9a9b910fa31bd8433e46b33a117e
Message:- Added the get_service_name() method.

- Corrected a bug where retries on locked db caused exceptions to be thrown in
the startup routine despite the retry handler successfully dealing with the
situation and waiting until the db was unlocked.
- Now stop deep recursion from happening in the above situation.
- Improved the logic in error handling inside the startup routine so that the
best error message is generated.
- Updates the documentation and corrected a few typos.
Changes:
Mlib/Monotone/AutomateStdio.pm (7 diffs)
Mlib/Monotone/AutomateStdio.pod (4 diffs)

File differences

lib/Monotone/AutomateStdio.pm
301301
302302
303303
304
304305
305306
306307
......
31673168
31683169
31693170
3170
3171
3171
3172
31723173
31733174
31743175
......
32453246
32463247
32473248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
32483276
32493277
32503278
......
48954923
48964924
48974925
4926
48984927
48994928
4929
4930
4931
4932
4933
4934
49004935
49014936
49024937
......
50125047
50135048
50145049
5015
5016
5017
50185050
5019
5020
5051
5052
50215053
5022
5023
5054
5055
50245056
5025
5057
5058
5059
5060
5061
5062
5063
5064
5065
50265066
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5067
50435068
5069
5070
5071
5072
5073
5074
5075
50445076
5045
5077
50465078
5047
5048
5079
5080
5081
5082
5083
50495084
5050
5051
5052
5053
5054
5055
5085
5086
50565087
5057
5088
50585089
5059
50605090
50615091
50625092
......
50715101
50725102
50735103
5074
5104
5105
5106
5107
50755108
5076
5077
5109
50785110
5079
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
50805135
5081
5082
5083
5084
50855136
50865137
50875138
50885139
50895140
5090
5141
50915142
50925143
50935144
......
52715322
52725323
52735324
5325
52745326
52755327
52765328
sub get_option($$$);
sub get_pid($);
sub get_revision($$$);
sub get_service_name($);
sub get_workspace_root($$);
sub get_ws_path($);
sub graph($$);
#
# Routine - get_db_name
#
# Description - Return the the file name of the Monotone database as given
# to the constructor.
# Description - Return the file name of the Monotone database as given to
# the constructor.
#
# Data - $self : The object.
# Return Value : The file name of the database as given to
#
##############################################################################
#
# Routine - get_service_name
#
# Description - Return the service name of the Monotone server as given to
# the constructor.
#
# Data - $self : The object.
# Return Value : The service name of the Monotone server as
# given to the constructor or undef if no
# service was specified.
#
##############################################################################
sub get_service_name($)
{
my $self = $_[0];
my $this = $class_records{$self->{$class_name}};
return $this->{network_service};
}
#
##############################################################################
#
# Routine - get_ws_path
#
# Description - Return the the workspace's base directory as either given
$header_err,
$line,
$my_pid,
$startup,
$version);
# Deep recursion guard.
$startup = $this->{startup};
local $this->{startup};
$this->{startup} = 1;
# Switch to the default locale. We only want to parse the output from
# Monotone in one language!
if ($mtn_version > 0.45)
{
local $@;
eval
{
my($char,
$last_char);
my($char,
$last_char);
# If we are connecting to a network service then make sure that
# it has sent us something before doing a blocking read.
# If we are connecting to a network service then make sure that it
# has sent us something before doing a blocking read.
if (defined($this->{network_service}))
if (defined($this->{network_service}))
{
my $poll_result;
for (my $i = 0;
$i < 10
&& ($poll_result =
$this->{poll}->poll($io_wait_handler_timeout))
== 0;
++ $i)
{
my $poll_result;
for (my $i = 0;
$i < 10
&& ($poll_result =
$this->{poll}->poll($io_wait_handler_timeout))
== 0;
++ $i)
{
&$io_wait_handler($self, $io_wait_handler_data);
}
if ($poll_result == 0)
{
$header_err = "Cannot connect to service `"
. $this->{network_service} . "'";
die(1);
}
&$io_wait_handler($self, $io_wait_handler_data);
}
if ($poll_result == 0)
{
$self->closedown();
&$croaker("Cannot connect to service `" .
$this->{network_service} . "'");
}
}
# Skip the header.
# Skip the header.
$char = "";
do
$char = $last_char = "";
while ($char ne "\n" || $last_char ne "\n")
{
$last_char = $char;
if (! sysread($this->{mtn_out}, $char, 1))
{
$last_char = $char;
if (! sysread($this->{mtn_out}, $char, 1))
{
$header_err = "Cannot get format header";
die(1);
}
$header_err = "Cannot get format header";
last;
}
while ($char ne "\n" || $last_char ne "\n");
}
};
}
# Set up the correct input handler depending upon the version of mtn.
}
# Get the interface version (remember also that if something failed
# above then this method will throw and exception giving the cause).
# above then this method will throw an exception giving the cause). If
# the database is locked then then this startup method will be called
# again by the method call below so use the $startup boolean to stop
# unnecessary recursion.
$self->interface_version(\$version);
if ($version =~ m/^(\d+)\.(\d+)$/)
if (! $startup)
{
$this->{mtn_aif_version} = $1;
if ($self->interface_version(\$version)
&& $version =~ m/^(\d+)\.(\d+)$/)
{
$this->{mtn_aif_version} = $1;
# We seem to be ok now despite any earlier failures so reset
# $header_err.
$header_err = undef;
}
else
{
if ($this->{db_is_locked})
{
&$croaker("Database is locked and there is either no "
. "registered retry handler or the handler "
. "returned false");
}
else
{
&$croaker("Cannot get automate stdio interface version "
. "number");
}
}
}
else
{
&$croaker("Cannot get automate stdio interface version number");
}
# This should never happen as getting the interface version would have
# reported the real issue, but handle any header read issues just in
# case.
&$croaker($header_err) if (defined($header_err));
&$croaker($header_err) if (! $startup && defined($header_err));
}
ws_constructed => undef,
cd_to_ws_root => $cd_to_ws_root,
convert_to_utf8 => $convert_to_utf8,
startup => undef,
mtn_options => undef,
mtn_pid => 0,
mtn_in => undef,
lib/Monotone/AutomateStdio.pod
66
77
88
9
9
1010
1111
1212
......
3636
3737
3838
39
39
4040
4141
4242
......
458458
459459
460460
461
462
461
462
463463
464464
465465
......
570570
571571
572572
573
574
575
576
577
578
573579
574580
575581
=head1 VERSION
0.07
0.08
=head1 SYNOPSIS
All automate commands have been implemented in this class except for the
`stdio' command, hopefully the reason is obvious :-). Versions of Monotone that
are supported by this class range from 0.35 up to and including the latest
version (currently 0.46). If you happen to be using a newer version of Monotone
version (currently 0.47). If you happen to be using a newer version of Monotone
then this class will hopefully largely work but without the support for new or
changed features.
=item B<$mtn-E<gt>get_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.
Return 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-E<gt>get_db_variables(\$buffer | \@list[, $domain])>
attribute - The name of the attribute that was set.
value - The value that the attribute was set to.
=item B<$mtn-E<gt>get_db_name()>
Return the service name of the Monotone server as given to the constructor.
(feature: MTN_REMOTE_CONNECTIONS)
=item B<$mtn-E<gt>get_workspace_root(\$buffer)>
Get the absolute path for the current workspace's root directory.

Archive Download the corresponding diff file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status