# # # add_dir "tests/automate_branches" # # add_file "tests/automate_branches/__driver__.lua" # content [821360189fc499a305e13c6712599fd89a40f9ae] # # add_file "tests/automate_branches/ignore_branch.lua" # content [8c35a6d05ad5e75f670db805acfaa1d27f9fd277] # # patch "ChangeLog" # from [a771d685caaac614e5ee32e66d341a6a74848573] # to [5b91bb976ad2e32a57165f3585e43010cbd7d41f] # # patch "automate.cc" # from [60c650f8ded7c4ba0225129600b8517f44eb9731] # to [af0878e853b034c51dbfbe8577403dc98933ed68] # # patch "cmd_automate.cc" # from [d6d54a3e8d5326f9ca16c6933404510d58bd7369] # to [cf5023075c21c358634a3dfff54010bc9f30b83e] # # patch "monotone.texi" # from [5e640c9f63179c7c04845b442592ecaa2bf2ad5f] # to [0a79130ab6d47f4b4accacb13be79772847f1ca5] # # patch "testsuite.lua" # from [21d2f5ef281214c171474776edde8a70c2e98210] # to [a958a32341dacf6077633d520376af16b54fb735] # ============================================================ --- tests/automate_branches/__driver__.lua 821360189fc499a305e13c6712599fd89a40f9ae +++ tests/automate_branches/__driver__.lua 821360189fc499a305e13c6712599fd89a40f9ae @@ -0,0 +1,32 @@ +-- -*-lua-*- +mtn_setup() + +-- automate branches on empty db should return successful and empty +check(mtn("automate", "branches"), 0, true, true) +check(fsize("stdout") == 0) +check(fsize("stderr") == 0) + +-- Let's create some branches, so we have stuff to list +writefile("foo.testbranch", "this is the testbranch version") +writefile("foo.otherbranch", "this version goes in otherbranch") + +copy("foo.testbranch", "foo") +check(mtn("add", "foo"), 0, false, false) +commit() + +copy("foo.otherbranch", "foo") +commit("otherbranch") + +-- automate branches should list 2 branches now +check(mtn("automate", "branches"), 0, true, true) +check(samelines("stdout", {"otherbranch", "testbranch"})) + +-- Create an ignore_branch hook to pass in +get("ignore_branch.lua") + +-- if we make a change in the branch.to.be.ignored it should not turn up in the list +copy("foo.testbranch", "in_ignored") +check(mtn("--rcfile=ignore_branch.lua", "add", "in_ignored"), 0, false, false) +commit("branch.to.be.ignored") +check(mtn("--rcfile=ignore_branch.lua", "automate", "branches"),0,true,true) +check(samelines("stdout", {"otherbranch", "testbranch"})) ============================================================ --- tests/automate_branches/ignore_branch.lua 8c35a6d05ad5e75f670db805acfaa1d27f9fd277 +++ tests/automate_branches/ignore_branch.lua 8c35a6d05ad5e75f670db805acfaa1d27f9fd277 @@ -0,0 +1,4 @@ +function ignore_branch(branchname) + if(branchname == "branch.to.be.ignored") then return true end + return false +end ============================================================ --- ChangeLog a771d685caaac614e5ee32e66d341a6a74848573 +++ ChangeLog 5b91bb976ad2e32a57165f3585e43010cbd7d41f @@ -1,3 +1,12 @@ +2006-07-01 Thomas Moschny + + * automate.cc (AUTOMATE(branches)): New function, almost similar + to ls branches. + * cmd_automate.cc (interface_version): Incremented. + * monotone.texi (Automation): Description of the new command added. + * tests/automate_branches/: Testing the new command. + * testsuite.lua: Activated new test. + 2006-06-30 Thomas Moschny * contrib/monotone.zsh_completion: New function ============================================================ --- automate.cc 60c650f8ded7c4ba0225129600b8517f44eb9731 +++ automate.cc af0878e853b034c51dbfbe8577403dc98933ed68 @@ -1180,7 +1180,34 @@ output << (*i).inner()() << endl; } +// Name: 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'. +// Output format: +// Zero or more lines, each the name of a branch. The lines are printed +// in alphabetically sorted order. +// Error conditions: +// None. +AUTOMATE(branches, N_("")) +{ + if (args.size() > 0) + throw usage(help_name); + vector names; + + app.db.get_branches(names); + sort(names.begin(), names.end()); + + for (vector::const_iterator i = names.begin(); + i != names.end(); ++i) + if (!app.lua.hook_ignore_branch(*i)) + output << (*i) << endl; +} + // Local Variables: // mode: C++ // fill-column: 76 ============================================================ --- cmd_automate.cc d6d54a3e8d5326f9ca16c6933404510d58bd7369 +++ cmd_automate.cc cf5023075c21c358634a3dfff54010bc9f30b83e @@ -54,7 +54,7 @@ i->second->run(args, root_cmd_name, app, output); } -static string const interface_version = "2.1"; +static string const interface_version = "2.2"; // Name: interface_version // Arguments: none ============================================================ --- monotone.texi 5e640c9f63179c7c04845b442592ecaa2bf2ad5f +++ monotone.texi 0a79130ab6d47f4b4accacb13be79772847f1ca5 @@ -5726,6 +5726,41 @@ @end table address@hidden mtn automate branches + address@hidden @strong address@hidden Arguments: + +None. + address@hidden Added in: + +2.2 + address@hidden Purpose: + +Prints all branch certs present in the revision graph, that are not +excluded by the lua hook @code{ignore_branch}. + address@hidden Sample output: + address@hidden +net.venge.monotone +net.venge.monotone.win32 address@hidden verbatim + address@hidden Output format: + +Zero or more lines, each the name of a branch. The lines are printed +in alphabetically sorted order. + address@hidden Error conditions: + +None. + address@hidden table + + @item mtn automate select @var{selector} @table @strong ============================================================ --- testsuite.lua 21d2f5ef281214c171474776edde8a70c2e98210 +++ testsuite.lua a958a32341dacf6077633d520376af16b54fb735 @@ -643,3 +643,4 @@ table.insert(tests, "invalid_--root_settings") table.insert(tests, "netsync_over_pipes") table.insert(tests, "ls_unknown_of_unknown_subdir") +table.insert(tests, "automate_branches")