# # # patch "ChangeLog" # from [a2bd76340a86855840ba62b75fc08274df33a8c7] # to [d387f0ce368ea1921ec044d04e24de3595fea23b] # # patch "automate.cc" # from [af0878e853b034c51dbfbe8577403dc98933ed68] # to [8f073a30cdecf9637306cd6dce8bc1767ad7e7b1] # # patch "monotone.texi" # from [0a79130ab6d47f4b4accacb13be79772847f1ca5] # to [f05dadb3d39c670a9f726fca0995a1872a20fca9] # ============================================================ --- ChangeLog a2bd76340a86855840ba62b75fc08274df33a8c7 +++ ChangeLog d387f0ce368ea1921ec044d04e24de3595fea23b @@ -1,3 +1,9 @@ +2006-07-04 Thomas Moschny + + * automate.cc (AUTOMATE(tags)): New function: List all tags in + basic_io format, possibly filtered by branch. + * monotone.texi (Automation): Description of the new added. + 2006-07-02 Timothy Brownawell * tester.txt: Short descriptions of the functions provided for use ============================================================ --- automate.cc af0878e853b034c51dbfbe8577403dc98933ed68 +++ automate.cc 8f073a30cdecf9637306cd6dce8bc1767ad7e7b1 @@ -31,6 +31,7 @@ #include "revision.hh" #include "transforms.hh" #include "vocab.hh" +#include "globish.hh" using std::allocator; using std::basic_ios; @@ -1208,6 +1209,99 @@ output << (*i) << endl; } +// Name: tags +// 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. +// 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 is thrown for illegal patterns. +AUTOMATE(tags, N_("[BRANCH_PATTERN]")) +{ + utf8 incl("*"); + bool filtering(false); + + if (args.size() == 1) { + incl = idx(args, 0); + filtering = true; + } + else if (args.size() > 1) + throw usage(name); + + globish_matcher match(incl, utf8()); + basic_io::printer prt; + basic_io::stanza stz; + stz.push_str_pair(symbol("format_version"), "1"); + prt.print_stanza(stz); + + vector > tag_certs; + app.db.get_revision_certs(tag_cert_name, tag_certs); + + for (vector >::const_iterator i = tag_certs.begin(); + i != tag_certs.end(); ++i) { + + cert tagcert(i->inner()); + vector > branch_certs; + app.db.get_revision_certs(tagcert.ident, branch_cert_name, branch_certs); + + bool show(!filtering); + vector branch_names; + + for (vector >::const_iterator j = branch_certs.begin(); + j != branch_certs.end(); ++j) { + + cert branchcert(j->inner()); + cert_value branch; + decode_base64(branchcert.value, branch); + string branch_name(branch()); + + if (app.lua.hook_ignore_branch(branch_name)) + continue; + + if (!show && match(branch_name)) + show = true; + branch_names.push_back(branch_name); + } + + if (show) { + basic_io::stanza stz; + cert_value tag; + decode_base64(tagcert.value, tag); + stz.push_str_pair(symbol("tag"), tag()); + stz.push_hex_pair(symbol("revision"), tagcert.ident); + stz.push_str_pair(symbol("signer"), tagcert.key()); + stz.push_str_multi(symbol("branches"), branch_names); + prt.print_stanza(stz); + } + } + output.write(prt.buf.data(), prt.buf.size()); +} + // Local Variables: // mode: C++ // fill-column: 76 ============================================================ --- monotone.texi 0a79130ab6d47f4b4accacb13be79772847f1ca5 +++ monotone.texi f05dadb3d39c670a9f726fca0995a1872a20fca9 @@ -5761,6 +5761,86 @@ @end table address@hidden mtn automate tags address@hidden + address@hidden @strong address@hidden Arguments: + +A branch pattern (optional). + address@hidden Added in: + +2.2 + address@hidden 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 address@hidden, it is neither printed, nor can it be matched by +a pattern. + address@hidden Sample output: + address@hidden +format_version "1" + + tag "monotree-0.3" +revision [35cff8e8ba14155f5f7ddf7965073f514fd60f61] + signer "address@hidden" +branches "net.venge.monotone.contrib.monotree" + + tag "monotree-0.2" +revision [5d288b39b49613b0d9dca8ece6b9a42c3773f35b] + signer "address@hidden" +branches "net.venge.monotone.contrib.monotree" + + tag "monotree-0.1" +revision [8a121346ce2920b6f85df68b3b620de96bd14a8d] + signer "address@hidden" +branches "net.venge.monotone.contrib" "net.venge.monotone.contrib.monotree" + + tag "monotree-0.4" +revision [f1afc520474f83c58262896ede027ef77226046e] + signer "address@hidden" +branches "net.venge.monotone.contrib.monotree" address@hidden verbatim + address@hidden 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: + address@hidden @option address@hidden 'tag' +the value of the tag cert, i.e. the name of the tag + address@hidden 'revision' +the hexadecimal id of the revision the tag is attached to + address@hidden 'signer' +the name of the key used to sign the tag cert + address@hidden 'branches' +a (possibly empty) list of all branches the tagged revision is on address@hidden table + +Stanzas are printed in arbitrary order. + address@hidden Error conditions: + +A run-time exception occures if an illegal branch pattern is +specified. + address@hidden table + + @item mtn automate select @var{selector} @table @strong