1Monotone::AutomateStdioU(s3e)r Contributed Perl DocumentaMtoinoontone::AutomateStdio(3)
2
3
4

NAME

6       Monotone::AutomateStdio - Perl interface to Monotone via automate stdio
7

VERSION

9       1.01
10

SYNOPSIS

12         use Monotone::AutomateStdio qw(:capabilities :severities);
13         my(@manifest,
14            $mtn,
15            @revs);
16         $mtn = Monotone::AutomateStdio->new("/home/fred/venge.mtn");
17         $mtn->select(\@revs, "h:net.venge.monotone");
18         $mtn->get_manifest_of(\@manifest, $revs[0])
19             or die("mtn: " . $mtn->get_error_message());
20

DESCRIPTION

22       The Monotone::AutomateStdio class gives a Perl developer access to
23       Monotone's automate stdio facility via an easy to use interface. All
24       command, option and output formats are handled internally by this
25       class. Any structured information returned by Monotone is parsed and
26       returned back to the caller as lists of records for ease of access
27       (detailed below). One also has the option of accessing Monotone's
28       output as one large string should you prefer.
29
30       The mtn automate stdio subprocess is also controlled by this class. A
31       new subprocess is started, if necessary, when anything that requires it
32       is called. The subprocess is terminated on object destruction or when
33       $mtn->closedown() is called.
34
35       All automate commands have been implemented in this class except for
36       the `stdio' command, hopefully the reason is obvious :-). Versions of
37       Monotone that are supported by this class range from 0.35 up to and
38       including the latest version (currently 1.00). If you happen to be
39       using a newer version of Monotone then this class will hopefully
40       largely work but without the support for new or changed features.
41

CONSTRUCTORS

43       $mtn = Monotone::AutomateStdio->new([\@options])
44           Creates a new Monotone::AutomateStdio object, using the current
45           workspace's database.
46
47       $mtn = Monotone::AutomateStdio->new_from_db($db[, \@options])
48           Creates a new Monotone::AutomateStdio object, using the database
49           named in $db.
50
51       $mtn = Monotone::AutomateStdio->new_from_service($service, [\@options])
52           Creates a new Monotone::AutomateStdio object, using the named
53           network service (which is expressed as a hostname optionally
54           followed by a colon and a port number).
55
56           (feature: MTN_REMOTE_CONNECTIONS)
57
58       $mtn = Monotone::AutomateStdio->new_from_ws($ws[, \@options])
59           Creates a new Monotone::AutomateStdio object, using the workspace
60           named in $ws.
61
62       Please note that Monotone::AutomateStdio->new() is simply an alias for
63       Monotone::AutomateStdio->new_from_db().
64
65       The @options parameter specifies what options are to be passed to the
66       mtn subprocess. The currently supported list (in vaguely the format in
67       which it would be passed to the constructor) is:
68
69           ["--allow-default-confdir",
70            "--allow-workspace",
71            "--builtin-rcfile",
72            "--clear-rcfiles",
73            "--confdir"               => <Directory>,
74            "--key"                   => <Key To Be Used For Signatures>,
75            "--keydir"                => <Key Store Location>,
76            "--no-builtin-rcfile",
77            "--no-default-confdir",
78            "--no-standard-rcfiles",
79            "--no-workspace",
80            "--norc",
81            "--nostd",
82            "--rcfile"                => <LUA File To Load>,
83            "--root"                  => <Root Directory>,
84            "--ssh-sign"              => One of "check", "no" or "yes",
85            "--standard-rcfiles",
86            "--use-default-key"]
87

CLASS METHODS

89       Monotone::AutomateStdio->register_db_locked_handler([$handler[,
90       $client_data]])
91           Registers the handler specified as a subroutine reference in
92           $handler for database locked conditions. The value of $client_data
93           is simply passed to the handler and can be used by the caller to
94           provide a context. This is both a class method as well as an object
95           one. When used as a class method, the specified database locked
96           handler is used for all Monotone::AutomateStdio objects that do not
97           specify their own handlers. If no handler is given then the
98           database locked condition handling is reset to the default
99           behaviour.
100
101           The handler subroutine is given two arguments, the first one is the
102           Monotone::AutomateStdio object that encountered the locked database
103           and the second is the value passed in as $client_data when the
104           hander was registered. If the handler returns true then the request
105           that failed is retried, if false is returned (undef) then the
106           default behaviour is performed, which is to treat it like any other
107           error.
108
109           Typically one would register a database locked handler when you are
110           using this class in a long running application where it is quite
111           possible that a user might do an mtn sync in the background. For
112           example, mtn-browse uses this handler to display a `Database is
113           locked, please retry...' dialog window.
114
115       Monotone::AutomateStdio->register_error_handler($severity[, $handler[,
116       $client_data]])
117           Registers the handler specified as a subroutine reference in
118           $handler for errors of a certain severity as specified by
119           $severity. $severity can be one of MTN_SEVERITY_WARNING,
120           MTN_SEVERITY_ERROR or MTN_SEVERITY_ALL. The value of $client_data
121           is simply passed to the handler and can be used by the caller to
122           provide a context. This is a class method rather than an object one
123           as errors can be raised when calling a constructor. If no handler
124           is given then the error handling is reset to the default behaviour
125           for that severity level.
126
127           The handler subroutine is given three arguments, the first one is a
128           severity string that indicates the severity of the error being
129           handled (either MTN_SEVERITY_WARNING or MTN_SEVERITY_ERROR), the
130           second one is the error message and the third is the value passed
131           in as $client_data when the hander was registered.
132
133           Please note:
134
135           1)  Warnings can be generated internally or whenever a message is
136               received from an mtn subprocess that is flagged as being in
137               error. For example, this occurs when an invalid selector is
138               given to the $mtn->select() method. The subprocess does not
139               exit under these conditions. Errors, however, are generated
140               whenever this class detects abnormal behaviour such as output
141               that is formatted in an unexpected manor or output appearing on
142               the mtn subprocess's STDERR file descriptor. Under these
143               circumstances it is expected that the application should exit
144               or at least destroy any Monotone::AutomateStdio objects that
145               are in error.
146
147           2)  Whilst warnings result in false being returned by those methods
148               that return a boolean success indicator, errors always result
149               in an exception being thrown.
150
151           3)  If the severity is MTN_SEVERITY_ERROR then it is expected that
152               croak or die will be called by the handler, if this is not the
153               case then this class will call croak() upon return. If you need
154               to trap errors and prevent program exit then use an eval block
155               to protect yourself in the calling code.
156
157           4)  If a warning handler is registered then this can be used to
158               report problems via one routine rather than checking the
159               boolean success indicator returned by most methods in this
160               class.
161
162           5)  In order to get the severity constants into your namespace you
163               need to use the following to load in this library.
164
165                   use Monotone::AutomateStdio qw(:severities);
166
167       Monotone::AutomateStdio->register_io_wait_handler([$handler, $timeout[,
168       $client_data]])
169           Registers the handler specified as a subroutine reference in
170           $handler for I/O wait conditions. This class will call the handler
171           after waiting $timeout seconds for data to come from the mtn
172           subprocess. The value of $client_data is simply passed to the
173           handler and can be used by the caller to provide a context. This is
174           both a class method as well as an object one. When used as a class
175           method, the specified I/O wait handler is used for all
176           Monotone::AutomateStdio objects that do not specify their own
177           handlers. If no handler is given then I/O wait handling is reset to
178           the default behaviour.
179
180           The handler subroutine is given two arguments, the first one is the
181           Monotone::AutomateStdio object that is waiting for output from the
182           mtn subprocess and the second is the value passed in as
183           $client_data when the handler was registered.
184
185           Typically one would register an I/O wait handler when you are using
186           this class in an interactive application where it may be necessary
187           to do some periodic background processing whilst waiting for the
188           mtn subprocess to do something. For example, mtn-browse uses this
189           handler to process any outstanding Gtk2 events so that the
190           application can keep its windows up to date.
191
192       Monotone::AutomateStdio->suppress_utf8_conversion($suppress)
193           Controls whether UTF-8 conversion should be done on the data sent
194           to and from the mtn subprocess by this class. If $suppress is true
195           then UTF-8 conversion is not done, otherwise it is. The default
196           action is to do UTF-8 conversion. This is both a class method as
197           well as an object one. When used as a class method, the setting is
198           used for all applicable Monotone::AutomateStdio objects that do not
199           specify their own setting.
200
201       Monotone::AutomateStdio->switch_to_ws_root($switch)
202           Controls whether this class automatically switches to a workspace's
203           root directory before running the mtn subprocess. If $switch is
204           true then the switch to the workspace's root directory is done,
205           otherwise it is not. The default action is to do the switch as this
206           is generally safer. This setting only affects objects constructed
207           from calling Monotone::AutomateStdio->new() and
208           Monotone::AutomateStdio->new_from_db(). This is both a class method
209           as well as an object one. When used as a class method, the setting
210           is used for all applicable Monotone::AutomateStdio objects that do
211           not specify their own setting.
212

OBJECT METHODS

214       See http://monotone.ca/monotone.html for a complete description of the
215       mtn automate commands.
216
217       Methods that return data from the mtn subprocess do so via their first
218       argument. This argument is a reference to either a scalar or a list
219       depending upon whether the data returned by the method is raw data or a
220       list of items respectively. Methods that return lists of records,
221       rather than a simple list of scalar items, also provide the option of
222       returning the data as one raw chunk if the reference points to a scalar
223       rather than a list. Therefore:
224
225           $mtn->get_manifest_of(\$buffer);
226
227       would simply put the output from the `get_manifest_of' command into the
228       variable named $buffer, whereas:
229
230           $mtn->get_manifest_of(\@list);
231
232       would return the output as a list of records (actually anonymous hashes
233       to be precise). However:
234
235           $mtn->get_file(\$buffer, $file_id);
236
237       will always need a reference to a scalar and:
238
239           $mtn->select(\@list, $selector);
240
241       will always need a reference to a list (each item is just a string
242       containing a revision id rather than a record).
243
244       The one exception to the above is the $mtn->generate_key() method,
245       which expects a reference to either a scalar or a hash as it only ever
246       returns one record's worth of information.
247
248       The remaining arguments depend upon the mtn command being used.
249
250       The following methods are provided:
251
252       $mtn->ancestors(\@list, $revision_id ...)
253           Get a list of ancestors for the specified revisions.
254
255       $mtn->ancestry_difference(\@list, $new_revision_id [, $old_revision_id
256       ...])
257           Get a list of ancestors for the specified revision, that are not
258           also ancestors for the specified old revisions.
259
260       $mtn->branches(\@list)
261           Get a list of branches.
262
263       $mtn->cert($revision_id, $name, $value)
264           Add the specified certificate to the specified revision.
265
266       $mtn->certs(\$buffer | \@list, $revision_id)
267           Get all the certificates for the specified revision. If \$buffer is
268           passed then the output from the command is simply placed into the
269           variable. However if \@list is passed then the output is returned
270           as a list of anonymous hashes, each one containing the following
271           fields:
272
273               key       - The signer of the cert. Prior to version 0.45 of
274                           Monotone this was in the form of typically an email
275                           address. From version 0.45 onwards this is now a
276                           hash. (feature: MTN_HASHED_SIGNATURES)
277               signature - Signer status. Values can be one of "ok", "bad" or
278                           "unknown".
279               name      - The cert name.
280               value     - Its value.
281               trust     - Its trust status. Values can be one of "trusted" or
282                           "untrusted".
283
284       $mtn->checkout(\@options, $ws_dir)
285           Create a new workspace in the directory specified by $ws_dir. One
286           can optionally specify the branch and revision if required. Please
287           note that this command changes the current working directory of the
288           mtn subprocess. If this is not what you want then the subprocess
289           can simply be restarted by using the $mtn->closedown() method.
290
291           The $options argument is a list of valid options, with some having
292           arguments. For example, one could call this method specifying all
293           of the options like this:
294
295               $mtn->checkout(["branch"   => "net.venge.monotone",
296                               "revision" => "t:monotone-0.35",
297                               "move-conflicting-paths"],
298                              "my-mtn-ws");
299
300           (feature: MTN_CHECKOUT)
301
302       $mtn->children(\@list, $revision_id)
303           Get a list of children for the specified revision.
304
305       $mtn->closedown()
306           If started then stop the mtn subprocess. Please note that the mtn
307           subprocess is automatically stopped when the related object is
308           destroyed. This method is provided so that application developers
309           can conveniently control when the subprocess is active.
310
311       $mtn->common_ancestors(\@list, $revision_id ...)
312           Get a list of revisions that are all ancestors of the specified
313           revision(s).
314
315       $mtn->content_diff(\$buffer[, \@options[, $revision_id1,
316       $revision_id2[, $file_name ...]]])
317           Get the difference between the two specified revisions, optionally
318           limiting the output by using the specified options and file
319           restrictions. If the second revision id is undefined then the
320           workspace's current revision is used. If both revision ids are
321           undefined then the workspace's current and base revisions are used.
322           If no file names are listed then differences in all files are
323           reported.
324
325           The $options argument is a list of valid options, with some having
326           arguments. For example, one could call this method specifying all
327           of the options like this (feature: MTN_CONTENT_DIFF_EXTRA_OPTIONS):
328
329               $mtn->content_diff(\@result,
330                                  ["depth"   => 1,
331                                   "exclude" => "work.cc",
332                                   "reverse",
333                                   "with-header"],
334                                  "unix");
335
336       $mtn->db_get(\$buffer, $domain, $name)
337           Get the value of a database variable.
338
339           (feature: MTN_DB_GET, obsolete: replaced by
340           $mtn->get_db_variables())
341
342       $mtn->db_locked_condition_detected()
343           Check to see if the Monotone database was locked the last time a
344           command was issued.
345
346       $mtn->descendents(\@list, $revision_id ...)
347           Get a list of descendants for the specified revision(s).
348
349       $mtn->drop_attribute($path[, $key])
350           Drop attributes from the specified file or directory, optionally
351           limiting it to the specified attribute.
352
353           (feature: MTN_DROP_ATTRIBUTE)
354
355       $mtn->drop_db_variables($domain[, $name])
356           Drop variables from the specified domain, optionally limiting it to
357           the specified variable.
358
359           (feature: MTN_DROP_DB_VARIABLES)
360
361       $mtn->drop_public_key($key_id)
362           Drop the public key from the database for the specified key id
363           (either in the form of a name or hash id).
364
365           (feature: MTN_DROP_PUBLIC_KEY)
366
367       $mtn->erase_ancestors(\@list[, $revision_id ...])
368           For a given list of revisions, weed out those that are ancestors to
369           other revisions specified within the list.
370
371       $mtn->file_merge(\$buffer, $left_revision_id, $left_file_name,
372       $right_revision_id, $right_file_name)
373           Get the result of merging two files, both of which are on separate
374           revisions.
375
376           (feature: MTN_FILE_MERGE)
377
378       $mtn->generate_key(\$buffer | \%hash, $key_id, $pass_phrase)
379           Generate a new key for use within the database. If \$buffer is
380           passed then the output from the command is simply placed into the
381           variable. However if \%hash is passed then the output is returned
382           as one anonymous hash containing the following fields:
383
384               Prior to version 0.44 of Monotone:
385                   name              - The name of the key.
386                   public_hash       - The public hash code.
387                   private_hash      - The private hash code.
388                   public_locations  - A list of locations for the public hash
389                                       code. Values can be one of "database" or
390                                       "keystore".
391                   private_locations - A list of locations for the private hash
392                                       code. Values can be one of "database" or
393                                       "keystore".
394
395               From version 0.44 of Monotone onwards
396               (feature: MTN_COMMON_KEY_HASH):
397                   name              - The name of the key.
398                   hash              - The hash code (both public and private).
399                   public_locations  - A list of locations for the public hash
400                                       code. Values can be one of "database" or
401                                       "keystore".
402                   private_locations - A list of locations for the private hash
403                                       code. Values can be one of "database" or
404                                       "keystore".
405
406           Also known as $mtn->genkey().
407
408           (feature: MTN_GENERATE_KEY)
409
410       $mtn->get_attributes(\$buffer | \@list, $file_name)
411           Get the attributes of the specified file. If \$buffer is passed
412           then the output from the command is simply placed into the
413           variable. However if \@list is passed then the output is returned
414           as a list of anonymous hashes, each one containing the following
415           fields:
416
417               attribute - The name of the attribute.
418               value     - The value of the attribute.
419               state     - The status of the attribute. Values can be one of
420                           "added", "changed", "dropped" or "unchanged".
421
422           Also known as $mtn->attributes().
423
424           (feature: MTN_GET_ATTRIBUTES)
425
426       $mtn->get_base_revision_id(\$buffer)
427           Get the id of the revision upon which the workspace is based.
428
429       $mtn->get_content_changed(\@list, $revision_id, $file_name)
430           Get a list of revisions in which the content was most recently
431           changed, relative to the specified revision.
432
433       $mtn->get_corresponding_path(\$buffer, $source_revision_id, $file_name,
434       $target_revision_id)
435           For the specified file name in the specified source revision,
436           return the corresponding file name for the specified target
437           revision.
438
439       $mtn->get_current_revision(\$buffer | \@list[, \@options[, $path ...]])
440           Get the revision information for the current revision, optionally
441           limiting the output by using the specified options and file
442           restrictions. If \$buffer is passed then the output from the
443           command is simply placed into the variable. However if \@list is
444           passed then the output is returned in exactly the same format as
445           for the $mtn->get_revision() method.
446
447           The $options argument is a list of valid options, with some having
448           arguments. For example, one could call this method specifying all
449           of the options like this:
450
451               $mtn->get_current_revision(\@result,
452                                          ["depth"   => 1,
453                                           "exclude" => "work.cc"],
454                                          "unix");
455
456           (feature: MTN_GET_CURRENT_REVISION)
457
458       $mtn->get_current_revision_id(\$buffer)
459           Get the id of the revision that would be created if an unrestricted
460           commit was done in the workspace.
461
462       $mtn->get_db_name()
463           Return the file name of the Monotone database as given to the
464           constructor. If no such name was given then undef is returned.
465
466       $mtn->get_db_variables(\$buffer | \@list[, $domain])
467           Get the variables stored in the database, optionally limiting it to
468           the specified domain. If \$buffer is passed then the output from
469           the command is simply placed into the variable. However if \@list
470           is passed then the output is returned as a list of anonymous
471           hashes, each one containing the following fields:
472
473               domain - The domain name to which the variable belongs.
474               name   - The name of the variable.
475               value  - The value of the variable.
476
477           (feature: MTN_GET_DB_VARIABLES)
478
479       $mtn->get_error_message()
480           Return the last error message received from the mtn subprocess. An
481           empty string is returned if no error has occurred yet.
482
483           Please note that the error message is never cleared but just
484           overwritten.  Therefore one can use this method to determinate the
485           nature of an error once it has been discovered but not to actually
486           detect it in the first place. Use either an error handler or check
487           the return status of methods to detect error conditions.
488
489       $mtn->get_extended_manifest_of(\$buffer | \@list, $revision_id)
490           Get the extended manifest for the specified revision. If \$buffer
491           is passed then the output from the command is simply placed into
492           the variable. However if \@list is passed then the output is
493           returned as a list of anonymous hashes, each one containing one or
494           more of the following fields:
495
496               type         - The type of entry. Values can be one of "file" or
497                              "directory".
498               name         - The name of the directory or file.
499               file_id      - The id of the file. This field is only present if
500                              type is set to "file".
501               birth        - The id of the revision in which the node was first
502                              added.
503               content_mark - The id of the revision in which the contents of
504                              the file was last changed.
505               path_mark    - The id of the revision in which the file was last
506                              renamed.
507               size         - The size of the file's contents in bytes.
508               attributes   - A list of attributes for the file or directory.
509                              Each entry has the following fields:
510                                  attribute - The name of the attribute.
511                                  value     - The value of the attribute.
512               attr_mark    - A list of attributes and when they were lasted
513                              changed. Each entry has the following fields:
514                                  attribute   - The name of the attribute.
515                                  revision_id - The id of the revision in which
516                                                the attributes value was last
517                                                changed.
518               dormant_attr - A list of attributes that have previously been
519                              deleted.
520
521           (feature: MTN_GET_EXTENDED_MANIFEST_OF)
522
523       $mtn->get_file(\$buffer, $file_id)
524           Get the contents of the file referenced by the specified file id.
525
526       $mtn->get_file_of(\$buffer, $file_name[, $revision_id])
527           Get the contents of the specified file under the specified
528           revision. If the revision id is undefined then the current
529           workspace revision is used.
530
531       $mtn->get_file_size(\$buffer, $file_id)
532           Get the size of the file referenced by the specified file id.
533
534           (feature: MTN_GET_FILE_SIZE)
535
536       $mtn->get_manifest_of(\$buffer | \@list[, $revision_id])
537           Get the manifest for the current or specified revision. If \$buffer
538           is passed then the output from the command is simply placed into
539           the variable. However if \@list is passed then the output is
540           returned as a list of anonymous hashes, each one containing the
541           following fields:
542
543               type       - The type of entry. Values can be one of "file" or
544                            "directory".
545               name       - The name of the directory or file.
546               file_id    - The id of the file. This field is only present if
547                            type is set to "file".
548               attributes - A list of attributes for the file or directory. Each
549                            entry has the following fields:
550                                attribute - The name of the attribute.
551                                value     - The value of the attribute.
552
553       $mtn->get_option(\$buffer, $option_name)
554           Get the value of an option stored in a workspace's _MTN directory.
555
556       $mtn->get_pid()
557           Return the process id of the mtn subprocess spawned by this class.
558           Zero is returned if no subprocess is thought to exist. Also if the
559           subprocess should exit unexpectedly then this method will carry on
560           returning its process id until the $mtn->closedown() method is
561           called.
562
563       $mtn->get_public_key(\$buffer, $key_id)
564           Get the public key for the specified key id (either in the form of
565           a name or hash id).
566
567           (feature: MTN_GET_PUBLIC_KEY)
568
569       $mtn->get_revision(\$buffer | \@list, $revision_id)
570           Get the revision information for the current or specified revision.
571           If \$buffer is passed then the output from the command is simply
572           placed into the variable. However if \@list is passed then the
573           output is returned as a list of anonymous hashes, each one
574           containing a variety of fields depending upon the type of entry:
575
576               type - The type of entry. Values can be one of "add_dir",
577                      "add_file", "clear", "delete", "new_manifest",
578                      "old_revision", "patch", "rename" or "set".
579
580               add_dir:
581                   name - The name of the directory that was added.
582
583               add_file:
584                   name    - The name of the file that was added.
585                   file_id - The id of the file.
586
587               clear:
588                   name      - The name of the file to which the attribute
589                               applied.
590                   attribute - The name of the attribute that was cleared.
591
592               delete:
593                   name - The name of the directory or file that was deleted.
594
595               new_manifest:
596                   manifest_id - The id of the revision's new manifest.
597
598               old_revision:
599                   revision_id - The id of the parent revision.
600
601               patch:
602                   name         - The name of the file that was changed.
603                   from_file_id - The file's old id.
604                   to_file_id   - The file's new id.
605
606               rename:
607                   from_name - The name of the file before the rename.
608                   to_name   - The name of the file after the rename.
609
610               set:
611                   name      - The name of the file that had an attribute set.
612                   attribute - The name of the attribute that was set.
613                   value     - The value that the attribute was set to.
614
615       $mtn->get_db_name()
616           Return the service name of the Monotone server as given to the
617           constructor.
618
619           (feature: MTN_REMOTE_CONNECTIONS)
620
621       $mtn->get_workspace_root(\$buffer)
622           Get the absolute path for the current workspace's root directory.
623
624           (feature: MTN_GET_WORKSPACE_ROOT)
625
626       $mtn->get_ws_path()
627           Return the the workspace's base directory as either given to the
628           constructor or deduced from the current workspace. If neither
629           condition holds true then undef is returned. Please note that the
630           workspace's base directory may differ from that given to the
631           constructor if the specified workspace path is actually a
632           subdirectory within that workspace.
633
634       $mtn->graph(\$buffer | \@list)
635           Get a complete ancestry graph of the database. If \$buffer is
636           passed then the output from the command is simply placed into the
637           variable. However if \@list is passed then the output is returned
638           as a list of anonymous hashes, each one containing the following
639           fields:
640
641               revision_id - The id of a revision.
642               parent_ids  - A list of parent revision ids.
643
644       $mtn->heads(\@list[, $branch_name])
645           Get a list of revision ids that are heads on the specified branch.
646           If no branch is given then the workspace's branch is used.
647
648       $mtn->identify(\$buffer, $file_name)
649           Get the file id, i.e. hash, of the specified file.
650
651       $mtn->ignore_suspend_certs($ignore)
652           Determine whether revisions with a suspend certificate are to be
653           ignored or not. If $ignore is true then suspend certificates are
654           ignored, otherwise they are honoured (in which case any suspended
655           revisions and branches that only have suspended revisions on their
656           heads will not be listed). The default behaviour is to honour
657           suspend certificates.
658
659           (feature: MTN_IGNORING_OF_SUSPEND_CERTS)
660
661       $mtn->interface_version(\$buffer)
662           Get the version of the mtn automate interface.
663
664       $mtn->inventory(\$buffer | \@list[, \@options[, $path ...]])
665           Get the inventory for the current workspace, optionally limiting
666           the output by using the specified options and file restrictions. If
667           \$buffer is passed then the output from the command is simply
668           placed into the variable. However if \@list is passed then the
669           output is returned as a list of anonymous hashes, each one
670           containing one or more of the following fields:
671
672               Prior to version 0.37 of Monotone:
673                   status       - The three inventory status characters for the
674                                  file or directory.
675                   crossref_one - The first cross-referencing number.
676                   crossref_two - The second cross-referencing number.
677                   name         - The name of the file or directory.
678
679               From version 0.37 of Monotone onwards
680               (feature: MTN_INVENTORY_IN_IO_STANZA_FORMAT):
681                   path     - The name of the file or directory.
682                   old_type - The type of the entry in the base manifest. Values
683                              can be one of "directory", "file" or "none".
684                   new_type - The type of the entry in the revision manifest.
685                              Values can be one of "directory", "file" or
686                              "none".
687                   fs_type  - The type of the entry on the file system. Values
688                              can be one of "directory", "file" or "none".
689                   old_path - The old name of the file or directory if it has
690                              been renamed in the revision manifest.
691                   new_path - The new name of the file or directory if it has
692                              been renamed in the revision manifest.
693                   birth    - The id of the revision in which the node was first
694                              added. Only from version 0.41 of Monotone
695                              onwards. (feature: MTN_INVENTORY_WITH_BIRTH_ID)
696                   status   - A list of status flags. Values can be one of
697                              "added", "dropped", "ignored", "invalid", "known",
698                              "missing", "rename_source", "rename_target" or
699                              "unknown".
700                   changes  - A list of change flags. Values can be one of
701                              "attrs" or "content".
702
703           Please note that some fields are not used by all entries, in which
704           case they are not present (use Perl's exists() function to
705           determine their presence and not defined()).
706
707           The $options argument is a list of valid options, with some having
708           arguments. For example, one could call this method specifying all
709           of the options like this (feature: MTN_INVENTORY_TAKING_OPTIONS):
710
711               $mtn->inventory(\@result,
712                               ["depth"   => 1,
713                                "exclude" => "work.cc",
714                                "no-corresponding-renames",
715                                "no-ignored",
716                                "no-unknown",
717                                "no-unchanged"],
718                               "unix");
719
720       $mtn->keys(\$buffer | \@list)
721           Get a list of all the keys known to mtn. If \$buffer is passed then
722           the output from the command is simply placed into the variable.
723           However if \@list is passed then the output is returned as a list
724           of anonymous hashes, each one containing the following fields:
725
726               Prior to version 0.44 of Monotone:
727                   name              - The name of the key.
728                   public_hash       - The public hash code.
729                   private_hash      - The private hash code.
730                   public_locations  - A list of locations for the public hash
731                                       code. Values can be one of "database" or
732                                       "keystore".
733                   private_locations - A list of locations for the private hash
734                                       code. Values can be one of "database" or
735                                       "keystore". This field is only present if
736                                       there is a private key.
737
738               Version 0.44 of Monotone (feature: MTN_COMMON_KEY_HASH):
739                   name              - The name of the key.
740                   hash              - The hash code (both public and private).
741                   public_locations  - A list of locations for the public hash
742                                       code. Values can be one of "database" or
743                                       "keystore".
744                   private_locations - A list of locations for the private hash
745                                       code. Values can be one of "database" or
746                                       "keystore". This field is only present if
747                                       there is a private key.
748
749               From version 0.45 of Monotone onwards
750               (feature: MTN_HASHED_SIGNATURES):
751                   given_name        - The name of the key as given when it was
752                                       created.
753                   hash              - The hash code (both public and private).
754                   local_name        - The local name of the key as returned by
755                                       the get_local_key_name() hook.
756                   public_locations  - A list of locations for the public hash
757                                       code. Values can be one of "database" or
758                                       "keystore".
759                   private_locations - A list of locations for the private hash
760                                       code. Values can be one of "database" or
761                                       "keystore". This field is only present if
762                                       there is a private key.
763
764           Please note that some fields are not used by all entries, in which
765           case they are not present (use Perl's exists() function to
766           determine their presence and not defined()).
767
768       $mtn->leaves(\@list)
769           Get a list of leaf revisions.
770
771       $mtn->log(\@list[, \@options[, $file_name]])
772           Get a list of revision ids that form a log history for an entire
773           project, optionally limiting the output by using the specified
774           options and file name restrictions.
775
776           The $options argument is a list of valid options, with some having
777           arguments. For example, one could call this method specifying all
778           of the options like this:
779
780               $mtn->log(\@list,
781                         ["clear-from",
782                          "clear-to",
783                          "from"       => "h:",
784                          "last"       => 20,
785                          "next"       => 30,
786                          "no-merges"
787                          "to"         => "t:test-checkin"],
788                         "Makefile.am");
789
790           (feature: MTN_LOG)
791
792       $mtn->lua(\$buffer, $lua_function[, $argument ...])
793           Call the specified LUA function with any required arguments.
794
795           (feature: MTN_LUA)
796
797       $mtn->packet_for_fdata(\$buffer, $file_id)
798           Get the contents of the file referenced by the specified file id in
799           packet format.
800
801       $mtn->packet_for_fdelta(\$buffer, $from_file_id, $to_file_id)
802           Get the file delta between the two files referenced by the
803           specified file ids in packet format.
804
805       $mtn->packet_for_rdata(\$buffer, $revision_id)
806           Get the contents of the revision referenced by the specified
807           revision id in packet format.
808
809       $mtn->packets_for_certs(\$buffer, $revision_id)
810           Get all the certs for the revision referenced by the specified
811           revision id in packet format.
812
813       $mtn->parents(\@list, $revision_id)
814           Get a list of parents for the specified revision.
815
816       $mtn->pull(\$buffer | \@list[,@options[, $uri]])
817           Synchronises database changes from the specified remote server to
818           the local database but not in the other direction. Other details
819           are identical to the $mtn->sync() method.
820
821           (feature: MTN_SYNCHRONISATION)
822
823       $mtn->push(\$buffer | \@list[,@options[, $uri]])
824           Synchronises database changes from the local database to the
825           specified remote server but not in the other direction. Other
826           details are identical to the $mtn->sync() method.
827
828           (feature: MTN_SYNCHRONISATION)
829
830       $mtn->put_file(\$buffer, $base_file_id, \$contents)
831           Put the specified file contents into the database, optionally
832           basing it on the specified file id (this is used for delta
833           encoding). The file id is returned.
834
835       $mtn->put_public_key($public_key)
836           Put the specified public key data into the database.
837
838           (feature: MTN_PUT_PUBLIC_KEY)
839
840       $mtn->put_revision(\$buffer, \$contents)
841           Put the specified revision data into the database. The revision id
842           is returned. Please note that any newly created revisions have no
843           certificates associated with them and so these have to be added
844           using the $mtn->cert() method.
845
846       $mtn->read_packets($packet_data)
847           Decode and store the specified packet data in the database.
848
849           (feature: MTN_READ_PACKETS)
850
851       $mtn->register_error_handler($severity[, $handler [, $client_data]])
852           Registers an error handler for the object rather than the class.
853           For further details please see the description of the class method.
854
855       $mtn->register_db_locked_handler([$handler[, $client_data]])
856           Registers a database locked handler for the object rather than the
857           class. For further details please see the description of the class
858           method.
859
860       $mtn->register_io_wait_handler([$handler, $timeout [, $client_data]])
861           Registers an I/O wait handler for the object rather than the class.
862           For further details please see the description of the class method.
863
864       $mtn->register_stream_handle($stream[, $handle]])
865           Registers the file handle specified in $handle so that it will
866           receive data from the specified mtn output stream. $stream can be
867           one of MTN_P_STREAM or MTN_T_STREAM. If no file handle is given
868           then any existing file handle is unregistered for that stream.
869
870           Please note:
871
872           1)  It is vitally important that if you register some sort of pipe
873               or socket to receive mtn stream output, that any data sent down
874               it is read immediately and independently from the code calling
875               the method generating the output (either by using a thread or
876               another process). Not doing so could easily cause a deadlock
877               situation to occur where the method stops processing, waiting
878               for the pipe or socket to empty before proceeding.
879
880           2)  The output streams are largely sent as received from the mtn
881               subprocess (please refer to the Monotone documentation for
882               further details on the format). The only difference is that
883               since the `l' or last message (which marks the end of a
884               command's output) is only sent once by mtn, this class
885               duplicates it onto any registered stream so that the reader
886               knows when there is no more data for a command.
887
888           3)  In order to get the stream constants into your namespace you
889               need to use the following to load in this library.
890
891                   use Monotone::AutomateStdio qw(:streams);
892
893           (feature: MTN_STREAM_IO)
894
895       $mtn->roots(\@list)
896           Get a list of root revisions, i.e. revisions with no parents.
897
898       $mtn->select(\@list, $selector)
899           Get a list of revision ids that match the specified selector.
900
901       $mtn->set_attribute($path, $key, $value)
902           Set an attribute on the specified file or directory.
903
904           (feature: MTN_SET_ATTRIBUTE)
905
906       $mtn->set_db_variable($domain, $name, $value)
907           Set the value of a database variable.
908
909           Also known as $mtn->db_set().
910
911           (feature: MTN_SET_DB_VARIABLE)
912
913       $mtn->show_conflicts(\$buffer | \@list[, $branch][, $left_revision_id,
914       $right_revision_id])
915           Get a list of conflicts between the first two head revisions on the
916           current branch, optionally one can specify both head revision ids
917           and the name of the branch that they reside on. If \$buffer is
918           passed then the output from the command is simply placed into the
919           variable. However if \@list is passed then the output is returned
920           as a list of anonymous hashes, each one containing one or more of
921           the following fields:
922
923               ancestor          - The id of the common ancestor revision for
924                                   both revisions in conflict.
925               ancestor_file_id  - The common ancestor file id for both files in
926                                   conflict.
927               ancestor_name     - The name of the ancestor file or directory.
928               attr_name         - The name of the Monotone file or directory
929                                   attribute that is in conflict.
930               conflict          - The nature of the conflict. Values can be one
931                                   of "attribute", "content",
932                                   "directory_loop", "duplicate_name",
933                                   "invalid_name", "missing_root",
934                                   "multiple_names", "orphaned_directory" or
935                                   "orphaned_file".
936               left              - The id of the left hand revision that is in
937                                   conflict.
938               left_attr_value   - The value of the attribute on the file or
939                                   directory in the left hand revision.
940               left_file_id      - The id of the file in the left hand revision.
941               left_name         - The name of the file or directory in the left
942                                   hand revision.
943               left_type         - The type of conflict relating to the file or
944                                   directory in the left hand revision. Values
945                                   can be one of "added directory",
946                                   "added file", "deleted directory",
947                                   "pivoted root", "renamed directory" or
948                                   "renamed file".
949               node_type         - The type of manifest node. Values can be one
950                                   of "file" or "directory".
951               resolved_internal - Only present if the conflict can be resolved
952                                   internally by Monotone during the merge
953                                   process.
954               right             - The id of the right hand revision that is in
955                                   conflict.
956               right_attr_state  - The state of the attribute in the right hand
957                                   revision. Values can only be "dropped".
958               right_attr_value  - The value of the attribute on the file or
959                                   directory in the right hand revision.
960               right_file_id     - The id of the file in the right hand
961                                   revision.
962               right_name        - The name of the file or directory in the
963                                   right hand revision.
964               right_type        - The type of conflict relating to the file or
965                                   directory in the left revision. Values are as
966                                   documented for left_type.
967
968           Please note that some fields are not used by all entries, in which
969           case they are not present (use Perl's exists() function to
970           determine their presence and not defined()).
971
972           (feature: MTN_SHOW_CONFLICTS)
973
974       $mtn->supports($feature)
975           Determine whether a certain feature is available with the version
976           of Monotone that is currently being used by this object. The list
977           of valid features are:
978
979               MTN_CHECKOUT
980               MTN_COMMON_KEY_HASH
981               MTN_CONTENT_DIFF_EXTRA_OPTIONS
982               MTN_DB_GET
983               MTN_DROP_ATTRIBUTE
984               MTN_DROP_DB_VARIABLES
985               MTN_DROP_PUBLIC_KEY
986               MTN_FILE_MERGE
987               MTN_GENERATE_KEY
988               MTN_GET_ATTRIBUTES
989               MTN_GET_CURRENT_REVISION
990               MTN_GET_DB_VARIABLES
991               MTN_GET_EXTENDED_MANIFEST_OF
992               MTN_GET_FILE_SIZE
993               MTN_GET_PUBLIC_KEY
994               MTN_GET_WORKSPACE_ROOT
995               MTN_HASHED_SIGNATURES
996               MTN_IGNORING_OF_SUSPEND_CERTS
997               MTN_INVENTORY_IN_IO_STANZA_FORMAT
998               MTN_INVENTORY_TAKING_OPTIONS
999               MTN_INVENTORY_WITH_BIRTH_ID
1000               MTN_K_SELECTOR
1001               MTN_LOG
1002               MTN_LUA
1003               MTN_M_SELECTOR
1004               MTN_P_SELECTOR
1005               MTN_PUT_PUBLIC_KEY
1006               MTN_READ_PACKETS
1007               MTN_REMOTE_CONNECTIONS
1008               MTN_SELECTOR_FUNCTIONS
1009               MTN_SELECTOR_OR_OPERATOR
1010               MTN_SET_ATTRIBUTE
1011               MTN_SET_DB_VARIABLE
1012               MTN_SHOW_CONFLICTS
1013               MTN_STREAM_IO
1014               MTN_SYNCHRONISATION
1015               MTN_SYNCHRONISATION_WITH_OUTPUT
1016               MTN_U_SELECTOR
1017               MTN_UPDATE
1018               MTN_W_SELECTOR
1019
1020           In order to get these constants into your namespace you need to use
1021           the following to load in this library.
1022
1023               use Monotone::AutomateStdio qw(:capabilities);
1024
1025           Please note that if you see (feature: ...) then this means that
1026           whatever is being discussed is only available if $mtn->supports()
1027           returns true for the specified feature.
1028
1029       $mtn->sync(\$buffer | \@list[,@options[, $uri]])
1030           Synchronises database changes between the local database and the
1031           specified remote server. $uri specifies the name of the server, the
1032           port, the database and the branch pattern to synchronise to, for
1033           example "mtn://code.monotone.ca:8000/monotone?net.venge.monotone*".
1034           If \$buffer is passed then the output from the command is simply
1035           placed into the variable. However if \@list is passed then the
1036           output is returned as a list of anonymous hashes, each one
1037           containing one or more of the following fields (feature:
1038           MTN_SYNCHRONISATION_WITH_OUTPUT):
1039
1040               key              - The signing key id for the current item.
1041               receive_cert     - The name of the certificate that has just been
1042                                  received.
1043               receive_key      - The id of the key that has just been received.
1044               receive_revision - The id of the revision that has just been
1045                                  received.
1046               revision         - The id of the revision relating to the current
1047                                  item.
1048               send_cert        - The name of the certificate that has just been
1049                                  sent.
1050               send_key         - The id of the key that has just been sent.
1051               send_revision    - The id of the revision that has just been
1052                                  sent.
1053               value            - The value of the certificate.
1054
1055           The $options argument is a list of valid options, with some having
1056           arguments. For example, one could call this method specifying all
1057           of the options like this:
1058
1059               $mtn->sync(\$buffer,
1060                          ["dry-run",
1061                           "exclude"             => "experiments.hacks",
1062                           "key-to-push"         => "me@mydomain.com",
1063                           "max-netsync-version" => 2,
1064                           "min-netsync-version" => 1,
1065                           "set-default"],
1066                          "mtn://code.monotone.ca/monotone?net.venge.monotone");
1067
1068           (feature: MTN_SYNCHRONISATION)
1069
1070       $mtn->tags(\$buffer | \@list[, $branch_pattern])
1071           Get all the tags attached to revisions on branches that match the
1072           specified branch pattern. If no pattern is given then all branches
1073           are searched. If \$buffer is passed then the output from the
1074           command is simply placed into the variable. However if \@list is
1075           passed then the output is returned as a list of anonymous hashes,
1076           each one containing the following fields:
1077
1078               tag         - The name of the tag.
1079               revision_id - The id of a revision that the tag is attached to.
1080               signer      - The signer of the tag. Prior to version 0.45 of
1081                             Monotone this was in the form of typically an email
1082                             address. From version 0.45 onwards this is now a
1083                             hash. (feature: MTN_HASHED_SIGNATURES)
1084               branches    - A list of all branches that contain this revision.
1085
1086       $mtn->toposort(\@list[, $revision_id ...])
1087           Sort the specified revision ids such that the ancestors come out
1088           first.
1089
1090       $mtn->update([@options])
1091           Updates the current workspace to the specified revision and
1092           possible branch. If no options are specified then the workspace is
1093           updated to the head revision of the current branch.
1094
1095           The $options argument is a list of valid options, with some having
1096           arguments. For example, one could call this method specifying all
1097           of the options like this:
1098
1099               $mtn->update(["branch"                  => "experiments.hacks",
1100                             "move-conflicting-paths",
1101                             "revision"                => "h:"]);
1102
1103           (feature: MTN_UPDATE)
1104

RETURN VALUE

1106       Except for those methods listed below, all remaining methods return a
1107       boolean success indicator, true for success or false for failure.
1108
1109       The following constructors return Monotone::AutomateStdio objects:
1110
1111           Monotone::AutomateStdio->new()
1112           Monotone::AutomateStdio->new_from_db()
1113           Monotone::AutomateStdio->new_from_service()
1114           Monotone::AutomateStdio->new_from_ws()
1115
1116       The following method returns true or false (but it does not indicate
1117       success or failure):
1118
1119           $mtn->db_locked_condition_detected()
1120
1121       The following method returns an integer:
1122
1123           $mtn->get_pid()
1124
1125       The following methods return a string or undef:
1126
1127           $mtn->get_db_name()
1128           $mtn->get_error_message()
1129           $mtn->get_ws_path()
1130
1131       The following methods do not return anything:
1132
1133           Monotone::AutomateStdio->register_db_locked_handler()
1134           Monotone::AutomateStdio->register_error_handler()
1135           Monotone::AutomateStdio->register_io_wait_handler()
1136           Monotone::AutomateStdio->register_stream_handle()
1137           Monotone::AutomateStdio->suppress_utf8_conversion()
1138           $mtn->closedown()
1139
1140       Please note that the boolean true and false values used by this class
1141       are defined as 1 and undef respectively.
1142

EXAMPLES

1144   Detecting Warnings And Errors
1145       Errors cause exceptions to be thrown. Warnings cause the responsible
1146       method to return false rather than true.
1147
1148       Therefore warnings would typically be detected by using code like this:
1149
1150           $mtn->get_file(\$data, $file_id)
1151               or die('$mtn->get_file() failed with: '
1152                      . $mtn->get_error_message());
1153
1154       However this can get clumsy and cluttered after a while, especially
1155       when the calling application knows that there is very little likelihood
1156       of there being a problem. Having exceptions being thrown for warnings
1157       as well as errors may be a better approach. By doing:
1158
1159           Monotone::AutomateStdio->register_error_handler
1160               (MTN_SEVERITY_ALL,
1161                sub
1162                {
1163                    my($severity, $message) = @_;
1164                    die($message);
1165                });
1166
1167       or more tersely:
1168
1169           Monotone::AutomateStdio->register_error_handler
1170               (MTN_SEVERITY_ALL, sub { die($_[1]); });
1171
1172       at the beginning of your application will mean that all errors and
1173       warnings detected by this class will generate an exception, thus making
1174       the checking of a method's return status redundant.
1175
1176   Silently Retrying Operations When The Database Is Locked
1177       If the Monotone database is locked then, by default, this class will
1178       report that condition as a warning. However it may be more convenient
1179       to ask this class to silently retry the operation until it succeeds.
1180       This can easily be done by using the database locked handler as
1181       follows:
1182
1183           Monotone::AutomateStdio->register_db_locked_handler
1184               (sub { sleep(1); return 1; });
1185
1186       This will mean that should any database locked conditions occur then
1187       this class will silently sleep for one second before retrying the
1188       operation.
1189
1190   Dealing With Processing Lockouts And Delays
1191       Some requests sent to the mtn subprocess can take several seconds to
1192       complete and consequently this class will take that amount of time,
1193       plus a very small processing overhead, to return. Whilst one can get
1194       around this by using threads, another way is to register an I/O wait
1195       handler. For example:
1196
1197           Monotone::AutomateStdio->register_io_wait_handler
1198               (sub { WindowManager->instance()->update_gui(); }, 1);
1199
1200       will instruct this class to update the user display every second whilst
1201       it is waiting for the mtn subprocess to finish processing a request.
1202

NOTES

1204   Using This Class With Monotone Workspaces
1205       Certain features are only available when used inside a Monotone
1206       workspace, so consequently this class does support the use of
1207       workspaces. However certain aspects of a workspace can affect the mtn
1208       subprocess. For example, when you run mtn in a workspace's subdirectory
1209       then all file name arguments get translated into paths relative to the
1210       workspace's root directory (i.e. given a path of
1211       /home/freddy/workspace/include/system.h when one runs "mtn log
1212       system.h" in the include directory the file name gets changed to
1213       include/system.h).
1214
1215       This makes perfect sense on the command line but possibly less so when
1216       using mtn from inside a GUI application where the directory in which
1217       the application was launched is not as relevant. This is why this class
1218       runs the mtn subprocess in specific directories depending upon how the
1219       object is constructed. If the object is constructed by calling
1220       Monotone::AutomateStdio->new() or
1221       Monotone::AutomateStdio->new_from_db() with the name of a database,
1222       then the mtn subprocess is run in the root directory, otherwise it is
1223       run in the workspace's root directory. This guarantees correct
1224       behaviour.
1225
1226       If however you want the mtn subprocess to run in the current directory
1227       within a workspace then simply use the
1228       Monotone::AutomateStdio->switch_to_ws_root() method to before calling
1229       Monotone::AutomateStdio->new() without specifying a database.
1230
1231       Any changing of directory does not affect the caller.
1232
1233   UTF-8 Handling
1234       A Monotone database may contain UTF-8 characters. These characters
1235       would most commonly appear inside text files but may also appear in the
1236       names of files, branches and even in certificates. Later versions of
1237       Perl have built in support for UTF-8 strings and can represent this
1238       sort of data quite naturally without the developer really having to
1239       worry too much. For this reason this class automatically converts any
1240       data sent between Perl and a mtn subprocess to and from Perl's internal
1241       UTF-8 string format and the standard binary octet notation.
1242
1243       There may be times when this built in conversion is inappropriate and
1244       so one can simply switch it off by using the
1245       Monotone::AutomateStdio->suppress_utf8_conversion() method to before
1246       calling Monotone::AutomateStdio->new().
1247
1248       Please note that not everything is converted when using this class's
1249       built in UTF-8 conversion mechanism. This is mainly for efficiency. For
1250       example, there is no real point in converting revision or file ids as
1251       these are always represented as forty character hexadecimal strings.
1252       Likewise packet data is not converted as this is always formatted to
1253       use seven bit ASCII. However there is one case where no conversion is
1254       done for reasons other than efficiency, and that is when handling file
1255       content data. Apart from differentiating between binary and non-binary
1256       data, Monotone just treats file content data as a sequence of bytes. In
1257       order to decide whether a file's contents contains UTF-8 data this may
1258       involve looking for assorted patterns in the data or checking the file
1259       name's extension, all of which being beyond the scope of this class.
1260       Also it is a good idea to treat file content data as a simple sequence
1261       of octets anyway. Probably the only time that one would need to worry
1262       about UTF-8 based file content data is when an application is
1263       displaying it using something like Gtk2 (the Gtk2 bindings for Perl
1264       uses Perl's internal UTF-8 flag to determine whether a string needs to
1265       be handled as a UTF-8 string or as a simple sequence of octets). In
1266       this case, once a file's contents has been determined to contain text
1267       oriented data, one can use Perl's decode_utf8() function to do the
1268       conversion. For more information on Perl's handling of UTF-8 please see
1269       the documentation for Encode.
1270
1271   Process Handling
1272       There are situations where this class does legitimately terminate the
1273       mtn subprocess (for example when a database locked condition is
1274       detected). When this happens the subprocess is reaped and its id is
1275       reset, i.e. the $mtn->get_pid() method returns 0. However if the
1276       subprocess should exit unexpectedly whilst processing a request then an
1277       exception is raised but no reaping or process id resetting takes place.
1278       Therefore an application using this class may wish to have a signal
1279       handler registered for SIGCHILD signals that can indirectly trigger a
1280       call to the $mtn->closedown() method or destroy the object concerned in
1281       the event of an error. In order to distinguish between legitimate
1282       terminations of the mtn subprocess and failures, simply compare the
1283       reaped process id against that returned by the $mtn->get_pid() method.
1284       If there is a match then there is a problem, otherwise, as far as this
1285       class is concerned, there is nothing to worry about.
1286
1287       Please note that all SIGPIPE signals are set to be ignored as soon as
1288       the first mtn subprocess is started by this class.
1289
1290   Use Of SIGALRM
1291       In order to reliably shutdown the mtn subprocess, alarm() is used to
1292       timeout calls to waitpid(), allowing this class to kill off any
1293       obstinate mtn subprocesses that remain after having their STDIN, STDOUT
1294       and STDERR file descriptors closed. Normally closing the file
1295       descriptors will cause a clean exit, I have never known it not to, at
1296       which point any alarms are reset without any SIGALRM signal being
1297       generated.
1298
1299   General
1300       When the output of a command from the automate stdio interface changes
1301       dramatically, it will probably not be possible to protect Perl
1302       applications from those changes. This class is a convenience wrapper
1303       rather than something that will totally divorce you from the automate
1304       stdio interface. Also the chances are you will want the new type of
1305       output anyway.
1306
1307       No work will be done to support versions of Monotone older than 0.35,
1308       so if you are in that position then I strongly suggest that you upgrade
1309       to a later version of Monotone (you will get all the new features and
1310       bug fixes, go on you know want them :-)). Also once the automate stdio
1311       interface has remained stable for some time, support may be dropped for
1312       older versions in order to aid maintenance and regression testing.
1313
1314       The $mtn->get_content_changed() method is very slow in Monotone
1315       versions 0.40 and 0.41.
1316

SEE ALSO

1318       http://monotone.ca
1319

BUGS

1321       Your mileage may vary if this class is used with versions of Monotone
1322       older than 0.35 (automate stdio interface version 4.3).
1323
1324       This class is not thread safe. If you wish to use this class in a
1325       multi-threaded environment then you either need to use a separate
1326       object per thread or use threads::lock to protect each method call.
1327

AUTHORS

1329       Anthony Cooper with contributions and ideas from Thomas Keller.
1330       Currently maintained by Anthony Cooper. Please report all faults and
1331       suggestions to <support@coosoft.plus.com>.
1332
1334       Copyright (C) 2008 by Anthony Cooper <aecooper@coosoft.plus.com>.
1335
1336       This library is free software; you can redistribute it and/or modify it
1337       under the terms of the GNU Lesser General Public License as published
1338       by the Free Software Foundation; either version 3 of the License, or
1339       (at your option) any later version.
1340
1341       This library is distributed in the hope that it will be useful, but
1342       WITHOUT ANY WARRANTY; without even the implied warranty of
1343       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
1344       General Public License for more details.
1345
1346       You should have received a copy of the GNU Lesser General Public
1347       License along with this library; if not, write to the Free Software
1348       Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307
1349       USA.
1350
1351
1352
1353perl v5.12.3                      2011-07-02        Monotone::AutomateStdio(3)
Impressum