# # # 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