# # # add_dir "tests/automate_roots" # # add_file "tests/automate_roots/__driver__.lua" # content [13ab764570fb854374d4c2310dff78cfd7977371] # # patch "NEWS" # from [d3e8fe958f408728cc119ee596c7f687f171495f] # to [bf55b145df1846c77fedba93641e7f56a64de876] # # patch "automate.cc" # from [ee573f26aa839258423b024608db769f87f02483] # to [17904f5962e731be01985d059526a3710d02e2b2] # # patch "cmd_automate.cc" # from [14f92cbf9b27710882e81f435b1ec11b03ea2a69] # to [8b23b1c3fda2841bf1e5671cebdef0d3f67babc4] # # patch "monotone.texi" # from [ad2e9773940536622365d456c0c2ba1e8ad2dacb] # to [6c4cceb28a7abb8b32d636ff10cdb5d40055fc0c] # ============================================================ --- tests/automate_roots/__driver__.lua 13ab764570fb854374d4c2310dff78cfd7977371 +++ tests/automate_roots/__driver__.lua 13ab764570fb854374d4c2310dff78cfd7977371 @@ -0,0 +1,42 @@ +-- -*- lua -*- + +revs = {} + +mtn_setup() + +-- empty graph +check(mtn("automate", "roots"), 0, false, false) + +-- add something on first branch +addfile("testfile", "blah blah") +commit() +revs.a = base_revision() + +check(mtn("automate", "roots"), 0, true, false) +check(trim(readfile("stdout")) == revs.a) + +-- add another rev on that branch +writefile("testfile", "other stuff") +commit() +revs.b = base_revision() + + +-- now, make a new branch +remove("testfile") +remove("_MTN") +check(mtn("setup", "--branch=otherbranch", "."), 0, false, false) + +-- and add something there +addfile("otherfile", "blah blah") +commit() +revs.c = base_revision() +addfile("otherfile", "foo") +commit() +revs.d = base_revision() + +-- now check +check(mtn("automate", "roots"), 0, true, false) +check(qgrep(revs.a, "stdout")) +check(qgrep(revs.c, "stdout")) +check(not(qgrep(revs.b, "stdout"))) +check(not(qgrep(revs.d, "stdout"))) ============================================================ --- NEWS d3e8fe958f408728cc119ee596c7f687f171495f +++ NEWS bf55b145df1846c77fedba93641e7f56a64de876 @@ -11,6 +11,9 @@ - 'automate identify', an automate version of 'mtn identify'. + - 'automate roots', prints the roots of the revision graph, + i.e. all revisions that have no parents. + Other - Private keys are now stored more safely, using file ============================================================ --- automate.cc ee573f26aa839258423b024608db769f87f02483 +++ automate.cc 17904f5962e731be01985d059526a3710d02e2b2 @@ -415,6 +415,30 @@ AUTOMATE(leaves, "", options::opts::none output << (*i).inner()() << '\n'; } +// Name: roots +// Arguments: +// None +// Added in: 4.3 +// Purpose: Prints the roots of the revision graph, i.e. all revisions that +// have no parents. +// Output format: A list of revision ids, in hexadecimal, each followed by a +// newline. Revision ids are printed in alphabetically sorted order. +// Error conditions: None. +AUTOMATE(roots, "", options::opts::none) +{ + N(args.size() == 0, + F("no arguments needed")); + + // the real root revisions are the children of one single imaginary root + // with an empty revision id + set roots; + revision_id nullid; + app.db.get_revision_children(nullid, roots); + for (set::const_iterator i = roots.begin(); + i != roots.end(); ++i) + output << i->inner()() << '\n'; +} + // Name: parents // Arguments: // 1: a revision id ============================================================ --- cmd_automate.cc 14f92cbf9b27710882e81f435b1ec11b03ea2a69 +++ cmd_automate.cc 8b23b1c3fda2841bf1e5671cebdef0d3f67babc4 @@ -61,7 +61,7 @@ automate_command(utf8 cmd, vector find_automation(cmd, root_cmd_name).run(args, root_cmd_name, app, output); } -static string const interface_version = "4.2"; +static string const interface_version = "4.3"; // Name: interface_version // Arguments: none ============================================================ --- monotone.texi ad2e9773940536622365d456c0c2ba1e8ad2dacb +++ monotone.texi 6c4cceb28a7abb8b32d636ff10cdb5d40055fc0c @@ -6028,6 +6028,41 @@ @section Automation @end table address@hidden mtn automate roots + address@hidden @strong address@hidden Arguments: + +None. + address@hidden Added in: + +4.3 + address@hidden Purpose: + +Prints the roots of the revision graph, i.e. all revisions that have +no parents. + address@hidden Sample output: + address@hidden +276264b0b3f1e70fc1835a700e6e61bdbe4c3f2f address@hidden verbatim + address@hidden Output format: + +Zero or more lines, each a root 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. + address@hidden Error conditions: + +None. + address@hidden table + + @item mtn automate branches @table @strong