# # # patch "cmd_merging.cc" # from [9cc466edc80188777182d9d6c0102f8474abc961] # to [49f9eb9307131c070f76c887c9631e900d37fc7f] # # patch "lua-testsuite.lua" # from [8254404e53c3ad822023d7d80b059519e2694eba] # to [41e44b694e1d68e32ba5bf9bca044a11f48f1028] # # patch "tests/automate_show_conflicts_defaults/__driver__.lua" # from [9ebc1b4df17bd570c9a4c1e61b2c95fc7d61511f] # to [8bf64504ef078a917ff74b73d99d53e34fddda56] # ============================================================ --- cmd_merging.cc 9cc466edc80188777182d9d6c0102f8474abc961 +++ cmd_merging.cc 49f9eb9307131c070f76c887c9631e900d37fc7f @@ -949,7 +949,7 @@ CMD_AUTOMATE(show_conflicts, N_("[LEFT_R N_("Shows the conflicts between two revisions."), N_("If no arguments are given, left_revid and right_revid default to the" "first two heads that would be chosen by the merge command."), - options::opts::none) + options::opts::branch) { database db(app); project_t project(db); @@ -958,6 +958,9 @@ CMD_AUTOMATE(show_conflicts, N_("[LEFT_R if (args.size() == 0) { // get ids from heads + N(app.opts.branchname() != "", + F("please specify a branch, with --branch=BRANCH")); + set heads; project.get_branch_heads(app.opts.branchname, heads, app.opts.ignore_suspend_certs); @@ -986,7 +989,7 @@ CMD_AUTOMATE(show_conflicts, N_("[LEFT_R complete(app.opts, app.lua, project, idx(args,1)(), r_id); } else - throw usage(execid); + N(false, F("wrong argument count")); show_conflicts_core(db, l_id, r_id, true, output); } ============================================================ --- lua-testsuite.lua 8254404e53c3ad822023d7d80b059519e2694eba +++ lua-testsuite.lua 41e44b694e1d68e32ba5bf9bca044a11f48f1028 @@ -26,6 +26,25 @@ end return {monotone_path, "--ssh-sign=no", "--norc", "--rcfile", test.root .. "/test_hooks.lua", unpack(arg)} end +function mtn_outside_ws(...) + -- Return a mtn command string that is executed outside a workspace, + -- but specifies all appropriate options. + if monotone_path == nil then + monotone_path = os.getenv("mtn") + if monotone_path == nil then + err("'mtn' environment variable not set") + end + end + return {monotone_path, + "--ssh-sign=no", + "--norc", "--rcfile", test.root .. "/test_hooks.lua", + "--confdir="..test.root, + "--db=" .. test.root .. "/test.db", + "--keydir", test.root .. "/keys", + "address@hidden", + unpack(arg)} +end + -- function preexecute(x) -- return {"valgrind", "--tool=memcheck", unpack(x)} -- end ============================================================ --- tests/automate_show_conflicts_defaults/__driver__.lua 9ebc1b4df17bd570c9a4c1e61b2c95fc7d61511f +++ tests/automate_show_conflicts_defaults/__driver__.lua 8bf64504ef078a917ff74b73d99d53e34fddda56 @@ -38,12 +38,12 @@ chuck_1 = base_revision() chuck_1 = base_revision() -- Check that 'automate show_conflicts' picks the same heads to --- compare first as 'merge' does +-- compare first as 'merge' does. Use workspace options check(mtn("merge"), 1, false, false) -- mtn: [left] 19ab79c40805c9dc5e25d0b6fa5134291e0b42d9 = beth_1 -- mtn: [right] d8a8bc9623c1ff9c0a5c082e40f0ff8ec6b43e72 = chuck_1 -check(mtn("automate", "show_conflicts"), 0, true, false) +check(mtn_ws_opts("automate", "show_conflicts"), 0, true, false) parsed = parse_basic_io(readfile("stdout")) @@ -51,4 +51,22 @@ check_basic_io_line (3, parsed[3], "ance check_basic_io_line (2, parsed[2], "right", chuck_1) check_basic_io_line (3, parsed[3], "ancestor", base_2) +-- Check that 'automate show_conflicts' works outside workspace when options are specified +non_ws_dir = test.root .. "/.." +check(indir(non_ws_dir, mtn_outside_ws("automate", "show_conflicts", "--branch=testbranch")), 0, true, false) + +parsed = parse_basic_io(readfile("stdout")) + +check_basic_io_line (1, parsed[1], "left", beth_1) +check_basic_io_line (2, parsed[2], "right", chuck_1) +check_basic_io_line (3, parsed[3], "ancestor", base_2) + +-- Check error message when outside workspace when branch not specified +check(indir(non_ws_dir, mtn_outside_ws("automate", "show_conflicts")), 1, false, true) +check(qgrep("misuse: please specify a branch, with --branch=BRANCH", "stderr")) + +-- Check error message for wrong arg count +check(indir(non_ws_dir, mtn_outside_ws("automate", "show_conflicts", "rev1")), 1, false, true) +check(qgrep("wrong argument count", "stderr")) + -- end of file