Next: , Previous: Database, Up: Command Reference


5.9 Automation

This section contains subcommands of the mtn automate command, used for scripting monotone. All give output on stdout; they may also give useful chatter on stderr, including warnings and error messages.

mtn automate interface_version
Arguments:
None.
Added in:
0.0
Purpose:
Prints version of the automation interface. Major number increments whenever a backwards incompatible change is made to the automate command; minor number increments whenever any change is made (but is reset when major number increments).
Sample output:
          
          1.2
     

Output format:
A decimal number, followed by “.” (full stop/period), followed by a decimal number, followed by a newline, followed by end-of-file. The first decimal number is the major version, the second is the minor version.
Error conditions:
None.

mtn automate heads [branch]
Arguments:
One branch name, branch. If none is given, the current default branch is used.
Added in:
0.0
Purpose:
Prints the heads of branch branch.
Sample output:
          
          28ce076c69eadb9b1ca7bdf9d40ce95fe2f29b61
          75156724e0e2e3245838f356ec373c50fa469f1f
     

Output format:
Zero or more lines, each giving the ID of one head of the given branch. Each line consists of a revision ID, in hexadecimal, followed by a newline. The lines are printed in alphabetically sorted order.
Error conditions:
If the given branch contains no members or does not exist, then no lines are printed.

mtn automate ancestors rev1 [rev2 [...]]
Arguments:
One or more revision IDs, rev1, rev2, etc.
Added in:
0.2
Purpose:
Prints the ancestors of one or more revisions.
Sample output:
          
          28ce076c69eadb9b1ca7bdf9d40ce95fe2f29b61
          75156724e0e2e3245838f356ec373c50fa469f1f
     

Output format:
Zero or more lines, each giving the ID of one ancestor of the given revisions. Each line consists of a revision ID, in hexadecimal, followed by a newline. The lines are printed in alphabetically sorted order.

The output does not include rev1, rev2, etc., except if rev2 is itself an ancestor of rev1, then rev2 will be included in the output.

Error conditions:
If any of the revisions do not exist, prints nothing to stdout, prints an error message to stderr, and exits with status 1.

mtn automate common_ancestors rev1 [rev2 [...]]
Arguments:
One or more revision IDs, rev1, rev2, etc.
Added in:
2.1
Purpose:
Prints all revisions which are ancestors of all of the revisions given as arguments.
Sample output:
          
          28ce076c69eadb9b1ca7bdf9d40ce95fe2f29b61
          75156724e0e2e3245838f356ec373c50fa469f1f
     

Output format:
Zero or more lines, each giving the ID of one common ancestor of all the given revisions. Each line consists of a revision ID, in hexadecimal, followed by a newline. The lines are printed in alphabetically sorted order.

The output will include one of the argument revisions only if that revision is an ancestor of all other revisions given as arguments.

Error conditions:
If any of the revisions do not exist, prints nothing to stdout, prints an error message to stderr, and exits with status 1.

mtn automate parents rev
Arguments:
One revision ID, rev.
Added in:
0.2
Purpose:
Prints the immediate parents of a revision. This is like a non-recursive version of automate ancestors.
Sample output:
          
          28ce076c69eadb9b1ca7bdf9d40ce95fe2f29b61
          75156724e0e2e3245838f356ec373c50fa469f1f
     

Output format:
Zero or more lines, each giving the ID of one parent of the given revision. Each line consists of a revision ID, in hexadecimal, followed by a newline. The lines are printed in alphabetically sorted order.
Error conditions:
If the given revision rev does not exist, prints nothing to stdout, prints an error message to stderr, and exits with status 1.

mtn automate descendents rev1 [rev2 [...]]
Arguments:
One or more revision IDs, rev1, rev2, etc.
Added in:
0.1
Purpose:
Prints the descendants of one or more revisions.
Sample output:
          
          28ce076c69eadb9b1ca7bdf9d40ce95fe2f29b61
          75156724e0e2e3245838f356ec373c50fa469f1f
     

Output format:
Zero or more lines, each giving the ID of one descendant of the given revisions. Each line consists of a revision ID, in hexadecimal, followed by a newline. The lines are printed in alphabetically sorted order.

The output does not include rev1, rev2, etc., except that if rev2 is itself a descendant of rev1, then rev2 will be included in the output.

Error conditions:
If any of the revisions do not exist, prints nothing to stdout, prints an error message to stderr, and exits with status 1.

mtn automate children rev
Arguments:
One revision ID, rev.
Added in:
0.2
Purpose:
Prints the immediate children of a revision. This is like a non-recursive version of automate descendents.
Sample output:
          
          28ce076c69eadb9b1ca7bdf9d40ce95fe2f29b61
          75156724e0e2e3245838f356ec373c50fa469f1f
     

Output format:
Zero or more lines, each giving the ID of one child of the given revision. Each line consists of a revision ID, in hexadecimal, followed by a newline. The lines are printed in alphabetically sorted order.
Error conditions:
If the given revision rev does not exist, prints nothing to stdout, prints an error message to stderr, and exits with status 1.

mtn automate graph
Arguments:
None.
Added in:
0.2
Purpose:
Prints out the complete ancestry graph of this database.
Sample output:
          
          0c05e8ec9c6af4224672c7cc4c9ef05ae8bdb794
          27ebcae50e1814e35274cb89b5031a423c29f95a 5830984dec5c41d994bcadfeab4bf1bf67747b89
          4e284617c80bec7da03925062a84f715c1b042bd 27ebcae50e1814e35274cb89b5031a423c29f95a 657c756d24fb65213d59f4ae07e117d830dcc95b
     

Output format:
Zero or more lines, each giving ancestry information for one revision. Each line begins with a revision ID. Following this are zero or more space-prefixed revision IDs. Each revision ID after the first is a parent (in the sense of automate parents) of the first. For instance, in the above sample output, 0c05e8ec9c6af4224672c7cc4c9ef05ae8bdb794 is a root node, 27ebcae50e1814e35274cb89b5031a423c29f95a has one parent, and 4e284617c80bec7da03925062a84f715c1b042bd has two parents, i.e., is a merge node.

The output as a whole is alphabetically sorted by line; additionally, the parents within each line are alphabetically sorted.

Error conditions:
None.

mtn automate erase_ancestors [rev1 [rev2 [...]]]
Arguments:
One or more revision IDs, rev1, rev2, etc.
Added in:
0.1
Purpose:
Prints all arguments, except those that are an ancestor of some other argument. One way to think about this is that it prints the minimal elements of the given set, under the ordering imposed by the “child of” relation. Another way to think of it is if the arguments formed a branch, then we would print the heads of that branch. If there are no arguments, prints nothing.
Sample output:
          
          28ce076c69eadb9b1ca7bdf9d40ce95fe2f29b61
          75156724e0e2e3245838f356ec373c50fa469f1f
     

Output format:
Zero or more lines, each giving the ID of one descendant of the given revisions. Each line consists of a revision ID, in hexadecimal, followed by a newline. The lines are printed in alphabetically sorted order.
Error conditions:
If any of the revisions do not exist, prints nothing to stdout, prints an error message to stderr, and exits with status 1.

mtn automate toposort [rev1 [rev2 [...]]]
Arguments:
One or more revision IDs, rev1, rev2, etc.
Added in:
0.1
Purpose:
Prints all arguments, topologically sorted. I.e., if rev1 is an ancestor of rev2, then rev1 will appear before rev2 in the output; if rev2 is an ancestor of rev1, then rev2 will appear before rev1 in the output; and if neither is an ancestor of the other, then they may appear in either order. If there are no arguments, prints nothing.
Sample output:
          
          28ce076c69eadb9b1ca7bdf9d40ce95fe2f29b61
          75156724e0e2e3245838f356ec373c50fa469f1f
     

Output format:
A list of revision IDs, in hexadecimal, each followed by a newline. Revisions are printed in topologically sorted order.
Error conditions:
If any of the revisions do not exist, prints nothing to stdout, prints an error message to stderr, and exits with status 1.

mtn automate ancestry_difference new [old1 [old2 [...]]]
Arguments:
A “new” revision ID new, followed by zero or more “old” revision IDs old1, old2, etc.
Added in:
0.1
Purpose:
Prints all ancestors of the revision new, that are not also ancestors of one of the old revisions. For purposes of this command, “ancestor” is an inclusive term; for example, if new is an ancestor of old1, it will not be printed; but if new is not an ancestor of any of the “old” revisions, then it will be. Similarly, old1 will never be printed, because it is considered to be an ancestor of itself. The reason for the names is that if new a new revision, and old1, old2, etc. are revisions that you have processed before, then this command tells you which revisions are new since then.
Sample output:
          
          28ce076c69eadb9b1ca7bdf9d40ce95fe2f29b61
          75156724e0e2e3245838f356ec373c50fa469f1f
     

Output format:
A list of revision IDs, in hexadecimal, each followed by a newline. Revisions are printed in topologically sorted order.
Error conditions:
If any of the revisions do not exist, prints nothing to stdout, prints an error message to stderr, and exits with status 1.

mtn automate leaves
Arguments:
None.
Added in:
0.1
Purpose:
Prints the leaves of the revision graph, i.e. all revision that have no children. This is similar, but not identical to the functionality of heads, which prints every revision in a branch, that has no descendants in that branch. If every revision in the database was in the same branch, then they would be identical. Generally, every leaf is the head of some branch, but not every branch head is a leaf.
Sample output:
          
          28ce076c69eadb9b1ca7bdf9d40ce95fe2f29b61
          75156724e0e2e3245838f356ec373c50fa469f1f
     

Output format:
Zero or more lines, each a leaf of the revision graph. Each line consists of a revision ID, in hexadecimal, followed by a newline. The lines are printed in alphabetically sorted order.
Error conditions:
None.

mtn automate branches
Arguments:
None.
Added in:
2.2
Purpose:
Prints all branch certs present in the revision graph, that are not excluded by the Lua hook ignore_branch.
Sample output:
          
          net.venge.monotone
          net.venge.monotone.win32
     

Output format:
Zero or more lines, each the name of a branch. The lines are printed in alphabetically sorted order.
Error conditions:
None.

mtn automate tags [branch_pattern]
Arguments:
A branch pattern (optional).
Added in:
2.2
Purpose:
If a branch pattern is given, prints all tags that are attached to revisions on branches matched by the pattern; otherwise prints all tags of the revision graph.

If a branch name is ignored by means of the Lua hook ignore_branch, it is neither printed, nor can it be matched by a pattern.

Sample output:
          
          format_version "1"
          
               tag "monotree-0.3"
          revision [35cff8e8ba14155f5f7ddf7965073f514fd60f61]
            signer "njs@pobox.com"
          branches "net.venge.monotone.contrib.monotree"
          
               tag "monotree-0.2"
          revision [5d288b39b49613b0d9dca8ece6b9a42c3773f35b]
            signer "njs@pobox.com"
          branches "net.venge.monotone.contrib.monotree"
          
               tag "monotree-0.1"
          revision [8a121346ce2920b6f85df68b3b620de96bd14a8d]
            signer "njs@pobox.com"
          branches "net.venge.monotone.contrib" "net.venge.monotone.contrib.monotree"
          
               tag "monotree-0.4"
          revision [f1afc520474f83c58262896ede027ef77226046e]
            signer "njs@pobox.com"
          branches "net.venge.monotone.contrib.monotree"
     

Output format:
There is one basic_io stanza for each tag.

All stanzas are formatted by basic_io. Stanzas are separated by a blank line. Values will be escaped, '\' to '\\' and '"' to '\"'.

Each stanza has exactly the following four entries:

'tag'
the value of the tag cert, i.e. the name of the tag
'revision'
the hexadecimal id of the revision the tag is attached to
'signer'
the name of the key used to sign the tag cert
'branches'
a (possibly empty) list of all branches the tagged revision is on

Stanzas are printed in arbitrary order.

Error conditions:
A run-time exception occurs if an illegal branch pattern is specified.

mtn automate select selector
Arguments:
One selector (or combined selector).
Added in:
0.2
Purpose:
Print all revisions that match the given selector.
Sample output:
          
          28ce076c69eadb9b1ca7bdf9d40ce95fe2f29b61
          75156724e0e2e3245838f356ec373c50fa469f1f
     

Output format:
Zero or more lines, each giving the ID of one revision that matches the given selector. Each line consists of a revision ID, in hexadecimal, followed by a newline. Revision ids are printed in alphabetically sorted order.
Error conditions:
None.

mtn automate inventory
Arguments:
None.
Added in:
1.0
Purpose:
Prints the inventory of every file found in the workspace or its associated base manifest. Each unique path is listed on a line prefixed by three status characters and two numeric values used for identifying renames.
Sample output:
All basic status codes:
          
            M 0 0 missing
           AP 0 0 added
          D   0 0 dropped
          R   1 0 renamed-from-this
           R  0 1 renamed-to-this
            P 0 0 patched
              0 0 unchanged
            U 0 0 unknown
            I 0 0 ignored
     

Two files swapped:

          
          RR  1 2 unchanged
          RR  2 1 original
     

Recorded with monotone that two files were swapped, but they were not actually swapped in the filesystem. Thus they both appear as patched:

          
          RRP 1 2 unchanged
          RRP 2 1 original
     

Rename foo to bar; add new file foo:

          
          RAP 1 0 foo
           R  0 1 bar
     

Rotated files foo -> bar -> baz -> foo:

          
          RR  1 3 foo
          RR  2 1 bar
          RR  3 2 baz
     

Recorded the rotation of files foo -> bar -> baz -> foo, but the actual files in the workspace were not moved, so monotone interprets all files as having been patched:

          
          RRP 1 3 foo
          RRP 2 1 bar
          RRP 3 2 baz
     

Dropped but not removed and thus unknown:

          
          D U 0 0 dropped
     

Added a non-existent file which is thus missing:

          
           AM 0 0 added
     

Recorded a rename, but not moved in the filesystem, and thus unknown source and missing target:

          
          R U 1 0 original
           RM 0 1 renamed
     

Moved in the filesystem but no rename recorded, and thus missing source and unknown target:

          
            M 0 0 original
            U 0 0 renamed
     

Renamed and patched:

          
          R   1 0 original
           RP 0 1 renamed
     

Output format:
Each path is printed on its own line, prefixed by three status characters described below. The status is followed by a single space and two numbers, each separated by a single space, used for identifying renames. The numbers are followed by a single space and then the pathname, which includes the rest of the line. Directory paths are identified as ending with the "/" character, file paths do not end in this character.

The three status characters are as follows.

          
          column 1 pre-state
                ' ' the path was unchanged in the pre-state
                'D' the path was deleted from the pre-state
                'R' the path was renamed from the pre-state name
          column 2 post-state
                ' ' the path was unchanged in the post-state
                'R' the path was renamed to the post-state name
                'A' the path was added to the post-state
          column 3 file-state
                ' ' the file is known and unchanged from the current manifest version
                'P' the file is patched to a new version
                'U' the file is unknown and not included in the current manifest
                'I' the file is ignored and not included in the current manifest
                'M' the file is missing but is included in the current manifest
     

Note that out of the 45 possible status code combinations, only 26 are valid, detailed below.

          
          '   ' unchanged
          '  P' patched (contents changed)
          '  U' unknown (exists on the filesystem but not tracked)
          '  I' ignored (exists on the filesystem but excluded by Lua hook)
          '  M' missing (exists in the manifest but not on the filesystem)
          
          ' A ' added (invalid, add should have associated patch)
          ' AP' added and patched
          ' AU' added but unknown (invalid)
          ' AI' added but ignored (invalid, added files are no longer ignored)
          ' AM' added but missing from the filesystem
          
          ' R ' rename target
          ' RP' rename target and patched
          ' RU' rename target but unknown (invalid)
          ' RI' rename target but ignored (invalid)
          ' RM' rename target but missing from the filesystem
          
          'D  ' dropped
          'D P' dropped and patched (invalid)
          'D U' dropped and unknown (still exists on the filesystem)
          'D I' dropped and ignored
          'D M' dropped and missing (invalid)
          
          'DA ' dropped and added (invalid, add should have associated patch)
          'DAP' dropped and added and patched
          'DAU' dropped and added but unknown (invalid)
          'DAI' dropped and added but ignored (invalid, added files are no longer ignored)
          'DAM' dropped and added but missing from the filesystem
          
          'DR ' dropped and rename target
          'DRP' dropped and rename target and patched
          'DRU' dropped and rename target but unknown (invalid)
          'DRI' dropped and rename target but ignored (invalid)
          'DRM' dropped and rename target but missing from the filesystem
          
          'R  ' rename source
          'R P' rename source and patched (invalid)
          'R U' rename source and unknown (still exists on the filesystem)
          'R I' rename source and ignored
          'R M' rename source and missing (invalid)
          
          'RA ' rename source and added (invalid, add should have associated patch)
          'RAP' rename source and added and patched
          'RAU' rename source and added but unknown (invalid)
          'RAI' rename source and added but ignored (invalid, added files are no longer ignored)
          'RAM' rename source and added but missing from the filesystem
          
          'RR ' rename source and target
          'RRP' rename source and target and target patched
          'RRU' rename source and target and target unknown (invalid)
          'RRI' rename source and target and target ignored (invalid)
          'RRM' rename source and target and target missing
     

The two numbers are used to match up the pre-state and post-state of a rename. Imagine a situation where there are two renames. automate inventory will print something like:

          
          R   1 0 a
          R   2 0 b
           R  0 2 c
           R  0 1 d
     

Here the status characters tell us that a and b were renamed, and we can tell that one was renamed to c and one was renamed to d, but we can't tell which was renamed to which. To do that, we have to refer to the numbers. The numbers do not themselves mean anything; their only purpose is to let you match up the two “ends” of a rename. The 1 in the left column by a means that a was the source of a rename, and the 1 in the right column by d means that d was the target of that same rename. Similarly, the two 2's tell us that b was renamed to c.

There are two columns of numbers because the same file can simultaneously be the target and source of a rename. The number '0' is used as a meaningless placeholder in all cases where a file is not a source or target of a rename. Any non-zero number that occurs at all will occur exactly once in the first column and exactly once in the second column.

Full support for versioned directories is not yet complete and the inventory will only list entries for renamed or dropped directories.

Error conditions:
When executed from outside of a workspace directory, prints an error message to stderr, and exits with status 1.

mtn automate certs id
Arguments:
A revision ID id, for which any certificates will be printed.
Added in:
1.0
Purpose:
Prints all certificates associated with the given revision ID. Each certificate is contained in a basic IO stanza. For each certificate, the following values are provided:
          
          'key'
                a string indicating the key used to sign this certificate.
          'signature'
                a string indicating the status of the signature. Possible 
                values of this string are:
                      'ok'        : the signature is correct
                      'bad'       : the signature is invalid
                      'unknown'   : signature was made with an unknown key
          'name'
                the name of this certificate
          'value'
                the value of this certificate
          'trust'
                is this certificate trusted by the defined trust metric?
                Possible values of this string are:
                      'trusted'   : this certificate is trusted
                      'untrusted' : this certificate is not trusted
     

Sample output:
          
                key "emile@alumni.reed.edu"
          signature "ok"
               name "author"
              value "emile@alumni.reed.edu"
              trust "trusted"
          
                key "emile@alumni.reed.edu"
          signature "ok"
               name "branch"
              value "net.venge.monotone"
              trust "trusted"
          
                key "emile@alumni.reed.edu"
          signature "ok"
               name "changelog"
              value "propagate from branch 'net.venge.monotone.annotate' (head 76a886ef7c8ae12a4bba5fc2bd252557bf863aff)
                      to branch 'net.venge.monotone' (head 2490479a4e4e99243fead6d627d78291fde592f0)
          "
              trust "trusted"
          
                key "emile@alumni.reed.edu"
          signature "ok"
               name "date"
              value "2005-05-20T20:19:25"
              trust "trusted"
     

Output format:
All stanzas are formatted by basic_io. Stanzas are separated by a blank line. Values will be escaped, '\' to '\\' and '"' to '\"'.
Error conditions:
If a certificate is signed with an unknown public key, a warning message is printed to stderr. If the revision specified is unknown or invalid prints an error message to stderr and exits with status 1.

mtn automate stdio
Arguments:
none
Added in:
1.0
Modifications:
3.1
Added the 'o' item to the recognized input. This change should not break anything.

Purpose:
Allow multiple automate commands to be run from one instance of monotone.
Sample input:
          
          l6:leavese
          l7:parents40:0e3171212f34839c2e3263e7282cdeea22fc5378e
          o6:author7:Timothye l6:commite
     

Input format:
          
          [ 'o' <string> <string> [ <string> <string> [ ... ] ] 'e' ]
          'l' <string> [ <string> [ ... ] ] 'e'
     

The input is a series of commands. The command name plus arguments are provided as 'l' <string> [<string> ...] 'e', where <string> = <size> colon <data> . This may optionally be preceded by a set of key=value pairs (command options) as 'o' <string> <string> [<string> <string> ...] 'e', where strings come in pairs, key followed by value.

The space between the ending 'e' of one group of strings and the beginning 'l' or 'o' of the next is reserved. Any characters other than whitespace will cause an error.

Sample output:
          
          0:0:l:205:0e3171212f34839c2e3263e7282cdeea22fc5378
          1f4ef73c3e056883c6a5ff66728dd764557db5e6
          2133c52680aa2492b18ed902bdef7e083464c0b8
          23501f8afd1f9ee037019765309b0f8428567f8a
          2c295fcf5fe20301557b9b3a5b4d437b5ab8ec8c
          1:0:l:41:7706a422ccad41621c958affa999b1a1dd644e79
     

Output format:
The output consists of one or more packets for each command. A packet looks like:

<command number>:<err code>:<last?>:<size>:<output>

<command number> is a decimal number specifying which command this output is from. It is 0 for the first command, and increases by one each time.

<err code> is 0 for success, 1 for a syntax error, and 2 for any other error.

<last?> is 'l' if this is the last piece of output for this command, and 'm' if there is more output to come.

<size> is the number of bytes in the output.

<output> is a piece of the output of the command.

All but the last packet for a given command will have the <last?> field set to 'm'.

Error conditions:
If a badly formatted or invalid command is received, or a command is given with invalid arguments or options, prints an error message to standard error and exits with nonzero status. Errors in the commands run through this interface do not affect the exit status. Instead, the <err code> field in the output is set to 2, and the output of the command becomes whatever error message would have been given.

mtn automate get_revision
mtn automate get_revision id
Arguments:
Specifying the option id argument outputs the changeset information for the specified id. Otherwise, id is determined from the workspace.
Added in:
1.0
Purpose:
Prints change information for the specified revision id.
Sample output:
          
          format_version "1"
          
          new_manifest [bfe2df785c07bebeb369e537116ab9bb7a4b5e19]
          
          old_revision [429fea55e9e819a046843f618d90674486695745]
          
          patch "ChangeLog"
           from [7dc21d3a46c6ecd94685ab21e67b131b32002f12]
             to [234513e3838d423b24d5d6c98f70ce995c8bab6e]
          
          patch "std_hooks.lua"
           from [0408707bb6b97eae7f8da61af7b35364dbd5a189]
             to [d7bd0756c48ace573926197709e53eb24dae5f5f]
     

Output format:
There are several changes that are described; each of these is described by a different basic_io stanza. The first string pair of each stanza indicates the type of change represented.

All stanzas are formatted by basic_io. Stanzas are separated by a blank line. Values will be escaped, '\' to '\\' and '"' to '\"'.

Possible values of this first value are along with an ordered list of basic_io formatted stanzas that will be provided are:

          
          'format_version'
                used in case this format ever needs to change.
                format: ('format_version', the string "1")
                occurs: exactly once
          'new_manifest'
                represents the new manifest associated with the revision.
                format: ('new_manifest', manifest id)
                occurs: exactly one
          'old_revision'
                represents a parent revision.
                format: ('old_revision', revision id)
                occurs: either one or two times
          'delete
                represents a file or directory that was deleted.
                format: ('delete', path)
                occurs: zero or more times
          'rename'
                represents a file or directory that was renamed.
                format: ('rename, old filename), ('to', new filename)
                occurs: zero or more times
          'add_dir'
                represents a directory that was added.
                format: ('add_dir, path)
                occurs: zero or more times
          'add_file'
                represents a file that was added.
                format: ('add_file', path), ('content', file id)
                occurs: zero or more times
          'patch'
                represents a file that was modified.
                format: ('patch', filename), ('from', file id), ('to', file id)
                occurs: zero or more times
          'clear'
                represents an attr that was removed.
                format: ('clear', filename), ('attr', attr name)
                occurs: zero or more times
          'set'
                represents an attr whose value was changed.
                format: ('set', filename), ('attr', attr name), ('value', attr value)
                occurs: zero or more times
     

These stanzas will always occur in the order listed here; stanzas of the same type will be sorted by the filename they refer to. The 'delete' and following stanzas will be grouped under the corresponding 'old_revision' one.

Error conditions:
If the revision specified is unknown or invalid prints an error message to stderr and exits with status 1.

mtn automate get_base_revision_id
Arguments:
None.
Added in:
2.0
Purpose:
Prints the revision id the current workspace is based on. This is the “old_revision” value stored in _MTN/revision.
Sample output:
          
          28ce076c69eadb9b1ca7bdf9d40ce95fe2f29b61
     

Output format:
One line containing the base revision ID of the current workspace.
Error conditions:
If no workspace book keeping _MTN directory is found, prints an error message to stderr, and exits with status 1.

mtn automate get_current_revision_id
Arguments:
None.
Added in:
2.0
Purpose:
Prints the revision id of the current workspace. This is the id of the revision that would be committed by an unrestricted commit in the workspace.
Sample output:
          
          28ce076c69eadb9b1ca7bdf9d40ce95fe2f29b61
     

Output format:
One line containing the current revision id ID of the current workspace.
Error conditions:
If no workspace book keeping _MTN directory is found, prints an error message to stderr, and exits with status 1.

mtn automate get_manifest_of
mtn automate get_manifest_of revid
Arguments:
Specifying the optional revid argument outputs the manifest for the revision with the specified ID. Otherwise, outputs the manifest for the current workspace. (You can think of leaving the argument blank as meaning “give me the manifest of THIS”.)
Added in:
2.0
Purpose:
Prints the contents of the manifest associated with the given roster.
Sample output:
          
          format_version "1"
          
          dir ""
          
             file ".htaccess"
          content [e3915658cb464d05f21332e03d30dca5d94fe776]
          
             file "AUTHORS"
          content [80d8f3f75c9b517ec462233e155f7dfb93379f67]
          
             file "ChangeLog"
          content [fc74a48c7f73eedcbe1ea709755fbe819b29736c]
          
             file "LICENSE"
          content [dfac199a7539a404407098a2541b9482279f690d]
          
             file "README"
          content [440eec971e7bb61ccbb61634deb2729bb25931cd]
          
             file "TODO"
          content [e0ea26c666b37c5f98ccf80cb933d021ee55c593]
          
             file "branch.psp"
          content [b28ece354969314ce996f3030569215d685973d6]
          
             file "common.py"
          content [1fdb62e05fb2a9338d2c72ddc58de3ab2b3976fe]
          
             file "config.py.example"
          content [64cb5898e3a026b4782c343ca4386585e0c3c275]
          
             file "error.psp"
          content [7152c3ff110418aca5d23c374ea9fb92a0e98379]
          
             file "fileinbranch.psp"
          content [5d8536100fdf51d505b6f20bc9c16aa78d4e86a8]
          
             file "headofbranch.psp"
          content [981df124a0b5655a9f78c42504cfa8c6f02b267a]
          
             file "help.psp"
          content [a43d0588a69e622b2afc681678c2a5c3b3b1f342]
          
             file "html.py"
          content [18a8bffc8729d7bfd71d2e0cb35a1aed1854fa74]
          
             file "index.psp"
          content [c621827db187839e1a7c6e51d5f1a7f6e0aa560c]
          
             file "monotone.py"
          content [708b61436dce59f47bd07397ce96a1cfabe81970]
          
             file "revision.psp"
          content [a02b1c161006840ea8685e461fd07f0e9bb145a3]
          
             file "rss_feed.gif"
          content [027515fd4558abf317d54c437b83ec6bc76e3dd8]
          
             file "tags.psp"
          content [638140d6823eee5844de37d985773be75707fa25]
          
             file "tarofbranch.psp"
          content [be83f459a152ffd49d89d69555f870291bc85311]
          
             file "test.py"
          content [e65aace9237833ec775253cfde97f59a0af5bc3d]
             attr "mtn:execute" "true"
          
             file "utility.py"
          content [fb51955563d64e628e0e67e4acca1a1abc4cd989]
          
             file "viewmtn.css"
          content [8d04b3fc352a860b0e3240dcb539c1193705398f]
          
             file "viewmtn.py"
          content [7cb5c6b1b1710bf2c0fa41e9631ae43b03424a35]
          
             file "wrapper.py"
          content [530290467a99ca65f87b74f653bf462b28c6cda9]
     

Output format:
There is one basic_io stanza for each file or directory in the manifest.

All stanzas are formatted by basic_io. Stanzas are separated by a blank line. Values will be escaped, '\' to '\\' and '"' to '\"'.

Possible values of this first value are along with an ordered list of basic_io formatted stanzas that will be provided are:

          
          'format_version'
                used in case this format ever needs to change.
                format: ('format_version', the string "1")
                occurs: exactly once
          'dir':
                represents a directory.  The path "" (the empty string) is used
                to represent the root of the tree.
                format: ('dir', pathname)
                occurs: one or more times
          'file':
                represents a file.
                format: ('file', pathname), ('content', file id)
                occurs: zero or more times
     

In addition, 'dir' and 'file' stanzas may have attr information included. These are appended to the stanza below the basic dir/file information, with one line describing each attr. These lines take the form ('attr', attr name, attr value).

Stanzas are sorted by the path string.

Error conditions:
If the revision ID specified is unknown or invalid prints an error message to stderr and exits with status 1.

mtn automate attributes file
Arguments:
The argument file determines which file's attributes should be printed.
Added in:
3.0
Purpose:
Prints all attributes of the given file and the attribute states.
Sample output:
          
          format_version "1"
          
           attr "foo" "bar"
          state "added"
          
           attr "baz" "bat"
          state "dropped"
          
           attr "foobar" "foobat"
          state "unchanged"
     

Output format:
There is one basic_io stanza for each attribute of the given file.

All stanzas are formatted by basic_io. Stanzas are separated by a blank line and ordered by attribute name. Values will be escaped, '\' to '\\' and '"' to '\"'.

Each attribute stanza also contains another entry which tells the status of attribute. This entry can have one of the following four values:

  • 'added': the attribute has just been added to the file
  • 'dropped': the attribute has just been dropped from the file
  • 'unchanged': the attribute has not been changed since the last revision
  • 'changed': the attribute has been changed since the last revision

The status 'changed' can come up if an attribute foo has been dropped and added afterwards with another value, like

          
          $ mtn attr drop file.txt foo ; mtn attr set file.txt foo baz
     

If an attribute has been dropped, the output will still return the previously set value of the dropped attribute for convenience (obviously this is no longer recorded in the current workspace).

The complete format:

          
          'format_version'
                used in case this format ever needs to change.
                format: ('format_version', the string "1")
                occurs: exactly once
          'attr':
                represents an attribute.
                format: ('attr', key, value), ('state', [unchanged|changed|added|dropped])
                occurs: zero or more times
     

Error conditions:
If the file specified is unknown to the current workspace prints an error message to stderr and exits with status 1.

mtn automate content_diff [--revision=id1 [--revision=id2]] [files ...]
Arguments:
One or more file arguments restrict the diff output to these files, otherwise all changed files in the given revision(s) and/or current workspace are considered.

If zero or more revisions are given, the command behaves as follows:

  • no revision: the diff is done between the workspace revision and the parent (base) revision of this workspace
  • one revision: the diff is done between the workspace revision and the given revision id1,
  • two revisions: the diff is done between id1 and id2; no workspace is needed in this case.

Added in:
4.0
Purpose:
Prints the content changes between two revisions or a revision and the current workspace. This command differs from mtn diff in that way that it only outputs content changes and keeps quite on renames or drops, as the header of mtn diff is omitted (this is what mtn automate get_revision already provides).
Sample output:
          
          ============================================================
          --- guitone/res/i18n/guitone_de.ts      9857927823e1d6a0339b531c120dcaadd22d25e9
          +++ guitone/res/i18n/guitone_de.ts      0b4715dc296b1955b0707923d45d79ca7769dd3f
          @@ -1,6 +1,14 @@
           <?xml version="1.0" encoding="utf-8"?>
           <!DOCTYPE TS><TS version="1.1">
           <context>
          +    <name>AncestryGraph</name>
          +    <message>
          [...]
     

Output format:
The GNU unified diff format. If there have been no content changes, the output is empty.
Error conditions:
If more than two revisions are given or a workspace is required, but not found, prints to stderr and exits with status 1. If one or more file restrictions can't be applied, the command prints to stderr and exits as well.

mtn automate get_file id
Arguments:
The id argument specifies the file hash of the file to be output.
Added in:
1.0
Purpose:
Prints the contents of the specified file.
Sample output:
          
          If you've downloaded a release, see INSTALL for installation
          instructions.  If you've checked this out, the generated files are not
          included, and you must use "autoreconf --install" to create them.
          
          "make html" for docs, or read the .info file and / or man page.
     

Output format:
The file contents are output without modification.
Error conditions:
If the file id specified is unknown or invalid prints an error message to stderr and exits with status 1.

mtn automate get_file_of filename [--revision=id]
Arguments:
The filename argument specifies the filename of the file to be output.

If a revision id is given, the file's contents in that specific revision are printed. If no revision is given, the workspace's revision is used.

Added in:
4.0
Purpose:
Prints the contents of the specified file.
Sample output:
          
          If you've downloaded a release, see INSTALL for installation
          instructions.  If you've checked this out, the generated files are not
          included, and you must use "autoreconf --install" to create them.
          
          "make html" for docs, or read the .info file and / or man page.
     

Output format:
The file contents are output without modification.
Error conditions:
If the filename specified is unknown in the given revision or invalid, or if the given revision is unknown, prints an error message to stderr and exits with status 1.

mtn automate get_option option
Arguments:
The option argument specifies the option name of the option to be output.
Added in:
3.1
Purpose:
Prints an option from _MTN/option of the current workspace.
Sample output:
          
          net.venge.monotone
     

Output format:
The option value is written out without modification.
Error conditions:
If the option is unknown, prints an error message to stderr and exits with status 1.

mtn automate keys
Arguments:
None.
Added in:
1.1
Purpose:
Print all keys in basic_io format.
Sample output:
          
                      name "tbrownaw@gmail.com"
               public_hash [475055ec71ad48f5dfaf875b0fea597b5cbbee64]
              private_hash [7f76dae3f91bb48f80f1871856d9d519770b7f8a]
           public_location "database" "keystore"
          private_location "keystore"
          
                     name "tomfa@debian.org"
              public_hash [3ac4afcd86af28413b0a23b7d22b9401e15027fc]
          public_location "database"
          
                      name "underwater@fishtank.net"
               public_hash [115fdc73d87a5e9901d018462b21a1f53eca33a1]
              private_hash [b520d2cfe7d30e4ea1725fc4f34646fc5469b13d]
           public_location "keystore"
          private_location "keystore"
          
     

Output format:
For each key, a basic_io stanza is printed. The public_location and private_location items may have multiple values as shown above for public_location, one value for each place that the key is stored. If the private key does not exist, then the private_hash and private_location items will be absent. The keys are ordered alphabetically by name.
Error conditions:
None.

mtn automate packet_for_rdata id
Arguments:
The id specifies the revision to output an rdata packet for.
Added in:
2.0
Purpose:
Prints the revision data in packet format
Sample output:
          
          [rdata bdf3b10b5df0f17cc6c1b4b3351d84701bda59ed]
          H4sIAAAAAAAA/0XQS27DMAwE0L1PIfgArb4kte62NzACg5SoJEBsF7aRurev0UVzgJl5mLas
          E+/jU9ftvsymd33Xzfo9Tjzfm267GSgGwVarz6Valx0KtFYwii9VqUFCqJQ5X7puedRx1ef9
          r2rwHlSbi+BUSrF4xn1p0RInkmxTbmwREp/BL97LzfQfN56v+rlc+860dZnMED01jhILkURJ
          Ul0KPpGN1ueUwDHyiXF66Ywx+2IGD+0Uqg8aCzikAEzZNRXPmJKlkhMxSHuNzrofx/uq2/J4
          6njV/bZsu/zMPOlbOY4XJSD5KOrwXGdwpDGdfotZayQHKTAi5fRPqUWKcAMMIQfAjOK0nkfm
          6tFacjYgBPV46X4BtlpiNYUBAAA=
          [end]
     

Output format:
Revision data in monotone read compatible packet format.
Error conditions:
If id is unknown or invalid prints an error message to stderr and exits with status 1.

mtn automate packet_for_certs id
Arguments:
The id specifies the revision to output cert packets for.
Added in:
2.0
Purpose:
Prints the certs associated with a revision in packet format
Sample output:
          
          [rcert bdf3b10b5df0f17cc6c1b4b3351d84701bda59ed
                 branch
                 njs@pobox.com
                 bmV0LnZlbmdlLm1vbm90b25l]
          K90i1XHHmaMEMuwbPifFweLThJl0m7jigh2Qq6Z7TBwNJ6IMOjXWCizv73cacZ1CtzxFDVwQ
          SlqhNWiPQWxdcMp+Uuo+V8IFMKmvxVSTuVDukLMuNAQqpGL5S+a+tEj68NMq+KLKuL8kAAPc
          RoFD7GQlTS35S3RHWA4cnvqn+8U=
          [end]
          [rcert bdf3b10b5df0f17cc6c1b4b3351d84701bda59ed
                 date
                 njs@pobox.com
                 MjAwNi0wNC0wOFQxMTo1MDowMA==]
          araz9A8x6AlK6m6UhwnhUhk7cdyxeE2nvzj2gwaDvkaBxOq4SN23/wnaPqUXx1Ddn8smzyRY
          HN08xloYc0yNChp3wjbqx20REcsTg3XE4rN/sgCbqqw5hVT22a5ZhqkfkDeoeJvan0R0UBax
          ngKYo9eLuABNlmFX2onca75JW1E=
          [end]
          [rcert bdf3b10b5df0f17cc6c1b4b3351d84701bda59ed
                 author
                 njs@pobox.com
                 bmpzQHBvYm94LmNvbQ==]
          BLPOYhgLsAN+w7CwOsv9GfXnG3u7RNF1DTrWdn0AnYE1e+ptgTeMVWUI18H4OGL0B7wm08rv
          Pxk/hvsb8fBn1Kf5HDDO2pbjJ0xVzI9+p+TR0y5jJNZlVSTj+nvtPgvK9NzsdooYWnwlWmJv
          bOkAzQcZb8NMh8pbQkdHbR5uzMo=
          [end]
          [rcert bdf3b10b5df0f17cc6c1b4b3351d84701bda59ed
                 changelog
                 njs@pobox.com
                 MjAwNi0wNC0wOCAgTmF0aGFuaWVsIFNtaXRoICA8bmpzQHBvYm94LmNvbT4KCgkqIG5ldHh4
          L3Jlc29sdmVfZ2V0aG9zdGJ5bmFtZS5jeHggKHJlc29sdmVfaG9zdG5hbWUpOiAjaWZkZWYg
          b3V0CglXaW4zMi1pbmNvbXBhdGlibGUgZXJyb3IgcmVwb3J0aW5nIGNhbGwuCg==]
          Ncl4L/oEPctzVQixTKA6FrLceeHnLiXfeyeFDNmtUFYg9BMUcjWkeyKmaWknLvOcHortxjto
          K6pQ9E8S7zI+TpzFAhssg5a///rFL0+2GJU3t6pcHs6LC0Q4tbqzwKd/5+8GwT1gphbM1wm7
          KuzKthwqD3pp49GbgTrp8iWMTr0=
          [end]
     

Output format:
Cert data in monotone read compatible packet format.
Error conditions:
If id is unknown or invalid prints an error message to stderr and exits with status 1.

mtn automate packet_for_fdata id
Arguments:
The id specifies the file to output an fdata packet for.
Added in:
2.0
Purpose:
Prints the file data in packet format
Sample output:
          
          [fdata 229c7f621b65f7e4970ae5aaec993812b9daa1d4]
          H4sIAAAAAAAA/z2OO27DMBBEe51ioMaNrJzBpQAjTXKBBTW0CJPcgFw6yO1DCkG62Q/em83j
          R9vlRez6naPKzh2CwkipXFBJbO8fn7f7HV4LQq4mMYoFzdMYSnMj1xXY/lnuoHt2kB2hQpst
          PREPZhaxvvchskIKkdU6xsXWvQsk76MOUquGVolZmmmh0+xxvf7JZ5jCFXbU4KZ1muYkT+Kw
          FOez5q6uLuh9+9eoQawhez3Fp+VtHJNkfMmDHfALzWYfcAgBAAA=
          [end]
     

Output format:
File data in monotone read compatible packet format.
Error conditions:
If id is unknown or invalid prints an error message to stderr and exits with status 1.

mtn automate packet_for_fdelta from-id to-id
Arguments:
The from-id specifies the file to use as the base of the delta, and to-id specifies the file to use as the target of the delta.
Added in:
2.0
Purpose:
Prints the file delta in packet format
Sample output:
          
          [fdelta 597049a62d0a2e6af7df0b19f4945ec7d6458727
                  229c7f621b65f7e4970ae5aaec993812b9daa1d4]
          H4sIAAAAAAAA/0WOy0oEMRBF9/mKS2/c9LQg4t5lw+BGf6BIKtNhkpSkKop/b9II7m49OOfu
          eHp5dnvEj/SHL0aQ75qFAgcQGmcm5RXKjP3t/eP1ekWUhlTVKGeyJNXNoXU/s27AP8sf7O8D
          ZEdSSLd1JMaNKzeysY8ps4Iao4oNjM99eFdQDbMOSldDV8ZC3aSxlxpxufzJF5jANx6oyS2b
          c0uhO+OwkpezZhCvK0bf8TVrMLZUo5zi0/I4j4UqPunGA+B+AfHvKEIPAQAA
          [end]
     

Output format:
File delta data in monotone read compatible packet format.
Error conditions:
If from-id or to-id is unknown or invalid prints an error message to stderr and exits with status 1.

mtn automate get_content_changed id file
Arguments:
The id specifies a revision ID, from which content change calculations will be based. and file specifies the file for which to calculate revisions in which it was last changed.
Added in:
3.2
Purpose:
Returns a list of revision IDs in which the content was most recently changed, relative to the revision ID specified as id. This equates to a content mark following the *-merge algorithm.
Sample output:
          
            content_mark [276264b0b3f1e70fc1835a700e6e61bdbe4c3f2f]
     

Output format:
Zero or more basic_io stanzas, each specifying a revision ID in which a content mark is set.

The complete format:

          
          'content_mark'
                   the hexadecimal id of the revision the content mark is attached to
     

Error conditions:
If id or file is unknown or invalid prints an error message to stderr and exits with status 1.

mtn automate get_corresponding_path source_id file target_id
Arguments:
The source_id specifies a revision ID in which file is current extant. and file specifies the file whose name in target_id is to be determined; target_id specifies a revision ID.
Added in:
3.2
Purpose:
Given a the file name file in the source revision source_id, a filename will if possible be returned naming the file in the target revision target_id. This allows the same file to be matched between revisions, accounting for renames and other changes.
Sample output:
          
          file "foo"
     

Output format:
Zero or one basic_io stanzas. Zero stanzas will be output if the file does not exist within the target revision; this is not considered an error. If the file does exist in the target revision, a single stanza with the following details is output.

The complete format:

          
             'file'
                   the file name corresponding to "file name" (arg 2) in the target revision
     

Error conditions:
If the revision IDs source_id or target_id are unknown or invalid prints an error message to stderr and exits with status 1. If the file path file does not exist in the revision source_id or is invalid, prints an error message to stderr and exits with status 1. Note that file not existing in the revision target_id is not an error.

mtn automate db_get domain name
Arguments:
The domain and name specify the database variable which is returned.
Added in:
4.1
Purpose:
Read a database variable, see also Vars.
Sample output:
           
          off.net 
     

Output format:
Exactly the variable's content. Since this command is mainly intended for automate stdio it will not add a trailing newline.
Error conditions:
If the variable is unknown prints an error message to stderr and exits with status 1.

mtn automate db_put domain name value
Arguments:
The domain and name specify the database variable which is changed to value.
Added in:
4.1
Purpose:
Change a database variable, see also Vars.
Sample usage:
           
          mtn automate db_set database default-server off.net 
     

Output format:
No output.
Error conditions:
None.

mtn automate put_file [base-id] contents
Arguments:
The optional base-id specifies a file-id on which the contents are based on. This is used for delta encoding. contents are the contents of the new file.
Added in:
4.1
Purpose:
Preparation of a workspace-less commit. See also automate put_revision. Normally used via automate stdio.
Sample output:
           
          70a0f283898a18815a83df37c902e5f1492e9aa2 
     

Output format:
The sha1 sum of the contents, hex encoded.
Error conditions:
If the optional base id is unknown prints an error message to stderr and exits with status 1.

mtn automate put_revision revision-data
Arguments:
revision-data is the new revision. See example below. Note that the new_manifest entry is ignored – put_revision will ignore whatever you put here and calculate the correct manifest id itself. (However, for now, you must put 40 hex digits here – it's just that which particular digits you put are entirely irrelevant. All zeros is a good choice.) Monotone will also canonicalize your whitespace automatically. You do not need to worry about getting just the right amount of indentation in front of each line. However, everything else about your revision must be valid.
Added in:
4.1
Purpose:
Workspace-less commit. Normally used via automate stdio.
Sample argument:
               format_version "1"
               
               new_manifest [0000000000000000000000000000000000000004]
               
               old_revision []
               
               add_dir ""
               
               add_file "foo"
               content [5bf1fd927dfb8679496a2e6cf00cbe50c1c87145]
          

Sample output:
           
          4c2c1d846fa561601254200918fba1fd71e6795d 
     

Output format:
The new revision id, hex encoded.
Error conditions:
If the changeset is invalid prints an error message to stderr and exits with status 1. May abort on invalid formats. If the revision is already present in the database, prints a message to stderr noting this fact, but otherwise works as normal.

mtn automate cert revision name value
Arguments:
revision is an existing revision, name is the certificate name and value its value.
Added in:
4.1
Purpose:
automate stdio capable variant of mtn cert.
Sample usage:
           
          mtn automate cert 4c2c1d846fa561601254200918fba1fd71e6795d author tester@test.net 
     

Output format:
No output.
Error conditions:
If the revision is invalid prints an error message to stderr and exits with status 1.