# # # add_dir "tests/status_with_no_key" # # add_file "tests/status_with_no_key/__driver__.lua" # content [a65e4eb2fd9d38f9567219c46f1315a1dc52dbc6] # # patch "cmd_ws_commit.cc" # from [729a6ead62f91c4f1c8629938f15b5cfba69c5f4] # to [c7d6e3540bce1c1d5896a198376a4553c4df8654] # ============================================================ --- tests/status_with_no_key/__driver__.lua a65e4eb2fd9d38f9567219c46f1315a1dc52dbc6 +++ tests/status_with_no_key/__driver__.lua a65e4eb2fd9d38f9567219c46f1315a1dc52dbc6 @@ -0,0 +1,22 @@ +mtn_setup() + +-- normal, one specified key +check(mtn("status"), 0, true, false) +check(qgrep("address@hidden", "stdout")) + +-- explicitly choose no key +check(safe_mtn("status", "-k", ""), 0, true, false) +check(not qgrep("address@hidden", "stdout")) + +-- no key specified, with one available +check(remove("_MTN")) +check(safe_mtn("setup", "--branch=testbranch", "."), 0, false, false) +check(safe_mtn("status"), 0, true, false) +check(qgrep("address@hidden", "stdout")) + +-- no key specified, with multiple available +check(mtn("genkey", "address@hidden"), 0, false, false, string.rep("address@hidden", 2)) +check(remove("_MTN")) +check(safe_mtn("setup", "--branch=testbranch", "."), 0, false, false) +check(safe_mtn("status"), 0, true, false) +check(not qgrep("address@hidden", "stdout")) ============================================================ --- cmd_ws_commit.cc 729a6ead62f91c4f1c8629938f15b5cfba69c5f4 +++ cmd_ws_commit.cc c7d6e3540bce1c1d5896a198376a4553c4df8654 @@ -880,11 +880,25 @@ CMD(status, "status", "", CMD_REF(inform key_store keys(app); key_identity_info key; - get_user_key(app.opts, app.lua, db, keys, project, key.id, cache_disable); - project.complete_key_identity_from_id(keys, app.lua, key); + try + { + get_user_key(app.opts, app.lua, db, keys, project, key.id, cache_disable); + project.complete_key_identity_from_id(keys, app.lua, key); - if (!app.lua.hook_get_author(app.opts.branch, key, author)) - author = key.official_name(); + if (!app.lua.hook_get_author(app.opts.branch, key, author)) + author = key.official_name(); + } + catch (recoverable_failure & rf) + { + // If we can't figure out which key would be used for commit, that's no reason + // to make status fail. + if (rf.caused_by() == origin::user) + { + author = "???"; + } + else + throw; + } calculate_ident(rev, rid);