# # # add_file "tests/trust_hooks_and_trusted_command/hooks.lua" # content [e4438532ebf5ad2bb5501c961ac12ed625549d50] # # patch "NEWS" # from [62caab0d8d669bc9326493f45ca101a1230d5bcf] # to [42be1fee226b51e7984014789380d81acc68067f] # # patch "automate.cc" # from [bf0bf00deee9db8789f89f44d7d90fcb53e82179] # to [2796409829849a402d028dba43bec0d4148e8f75] # # patch "cmd_key_cert.cc" # from [80a189024eaca145211bd9567aab9daa1cfc0036] # to [1fdeeafa69f1aa0f5ea982eb756090195bb6ecb7] # # patch "selectors.cc" # from [652c0482c640f024d8a90402d325ca48b9170143] # to [614c27516fee8169f7135ad330f1bc7185594d8d] # # patch "selectors.hh" # from [8f23c72c0901a492c75f483b8c2c4316251b31ed] # to [8012106f2fa713db2a7e1b3b897a890b92ea36dd] # # patch "tests/test_hooks.lua" # from [d8e009b5e2c7d00afe4b301d60b8242936d6b794] # to [d2e867d633d38b67e6055b6c672cf3ac97278382] # # patch "tests/trust_hooks_and_trusted_command/__driver__.lua" # from [2ac6428fb5a5564c4f376a4566e041324c8cd88c] # to [14989f207695c9b6d1c4758d2448f2710d094bca] # ============================================================ --- tests/trust_hooks_and_trusted_command/hooks.lua e4438532ebf5ad2bb5501c961ac12ed625549d50 +++ tests/trust_hooks_and_trusted_command/hooks.lua e4438532ebf5ad2bb5501c961ac12ed625549d50 @@ -0,0 +1,23 @@ +-- Everything alice signs is trusted, nothing mallory signs is +-- trusted. For certs signed by other people, everything is +-- trusted except for one particular cert... +function get_revision_cert_trust(signers, id, name, val) + for k, v in pairs(signers) do + if v.given_name == "address@hidden" then return true end + if v.given_name == "address@hidden" then return false end + end + -- the id of the revision in which "badfile" is checked in + if (id == "4c71646d1def3c60b06d8358b1b7016d762e5e02" + and name == "bad-cert" and val == "bad-val") + then return false end + return true +end + +function get_manifest_cert_trust(signers, id, name, val) + return true +end + +function get_file_cert_trust(signers, id, name, val) + return true +end + ============================================================ --- NEWS 62caab0d8d669bc9326493f45ca101a1230d5bcf +++ NEWS 42be1fee226b51e7984014789380d81acc68067f @@ -57,12 +57,17 @@ Xxx Xxx 99 99:99:99 UTC 2010 commands such as `clone`, `automate remote` and `automate remote_stdio`. - - The import command now keeps the created bookkeeping root if + - The `import` command now keeps the created bookkeeping root if --dry-run is not specified. This makes it possible to re-use the import directory as workspace and is also more closely to what our documentation states, when it says that import is basically "setup with a twist". + - monotone no longer passes syntactically correct, but non-existent + revision ids through the selector machinery. The most visible + place for this change is `automate select`, which no longer + echoes every possible 40 hex-byte string. + New Features Bugs Fixed @@ -83,6 +88,10 @@ Xxx Xxx 99 99:99:99 UTC 2010 to write out _MTN/options on --dry-run (fixes monotone bug #30225) + - `mtn trusted` will no longer accept single bogus revision ids, + but instead validates if the given revision really exists in the + current database. + Other Sun Jun 13 22:13:53 UTC 2010 ============================================================ --- automate.cc bf0bf00deee9db8789f89f44d7d90fcb53e82179 +++ automate.cc 2796409829849a402d028dba43bec0d4148e8f75 @@ -520,6 +520,11 @@ CMD_AUTOMATE(select, N_("SELECTOR"), database db(app); project_t project(db); set completions; + + // FIXME: replace this with + // complete(app.opts, app.lua, project, idx(args, 0)(), completions); + // some time which errors out if no completions could be found for a + // specific selector - this breaks BC with earlier automate versions though expand_selector(app.opts, app.lua, project, idx(args, 0)(), completions); for (set::const_iterator i = completions.begin(); ============================================================ --- cmd_key_cert.cc 80a189024eaca145211bd9567aab9daa1cfc0036 +++ cmd_key_cert.cc 1fdeeafa69f1aa0f5ea982eb756090195bb6ecb7 @@ -227,8 +227,7 @@ CMD(trusted, "trusted", "", CMD_REF(key_ throw usage(execid); set rids; - expand_selector(app.opts, app.lua, project, idx(args, 0)(), rids); - diagnose_ambiguous_expansion(app.opts, app.lua, project, idx(args, 0)(), rids); + complete(app.opts, app.lua, project, idx(args, 0)(), rids); revision_id ident; if (!rids.empty()) ============================================================ --- selectors.cc 652c0482c640f024d8a90402d325ca48b9170143 +++ selectors.cc 614c27516fee8169f7135ad330f1bc7185594d8d @@ -37,6 +37,24 @@ using boost::shared_ptr; using boost::shared_ptr; +void +diagnose_ambiguous_expansion(options const & opts, lua_hooks & lua, + project_t & project, + string const & str, + set const & completions) +{ + if (completions.size() <= 1) + return; + + string err = (F("selection '%s' has multiple ambiguous expansions:") + % str).str(); + for (set::const_iterator i = completions.begin(); + i != completions.end(); ++i) + err += ("\n" + describe_revision(opts, lua, project, *i)); + + E(false, origin::user, i18n_format(err)); +} + class selector { public: @@ -904,37 +922,9 @@ expand_selector(options const & opts, lu set & completions) { shared_ptr sel = selector::create(opts, lua, project, str); - - // avoid logging if there's no expansion to be done - shared_ptr isel = boost::dynamic_pointer_cast(sel); - if (isel && isel->is_full_length()) - { - completions.insert(isel->get_assuming_full_length()); - return; - } - completions = sel->complete(project); } -void -diagnose_ambiguous_expansion(options const & opts, lua_hooks & lua, - project_t & project, - string const & str, - set const & completions) -{ - if (completions.size() <= 1) - return; - - string err = (F("selection '%s' has multiple ambiguous expansions:") - % str).str(); - for (set::const_iterator i = completions.begin(); - i != completions.end(); ++i) - err += ("\n" + describe_revision(opts, lua, project, *i)); - - E(false, origin::user, i18n_format(err)); -} - - // Local Variables: // mode: C++ // fill-column: 76 ============================================================ --- selectors.hh 8f23c72c0901a492c75f483b8c2c4316251b31ed +++ selectors.hh 8012106f2fa713db2a7e1b3b897a890b92ea36dd @@ -31,19 +31,15 @@ void complete(options const & opts, lua_ project_t & project, std::string const & str, revision_id & completion); -// For extra control, use these functions. expand_selector is just like the +// For extra control, use expand_selector, which is just like the // first overload of complete() except that it produces no progress messages -// or usage errors. diagnose_ambiguous_expansion generates the canonical -// usage error if the set it is handed has more than one element. +// or usage errors. The only place where this is currently still +// in use is automate select. void expand_selector(options const & opts, lua_hooks & lua, project_t & project, std::string const & str, std::set & completions); -void diagnose_ambiguous_expansion(options const & opts, lua_hooks & lua, project_t & project, - std::string const & str, std::set const & completions); - - #endif // __SELECTORS_HH__ // Local Variables: ============================================================ --- tests/test_hooks.lua d8e009b5e2c7d00afe4b301d60b8242936d6b794 +++ tests/test_hooks.lua d2e867d633d38b67e6055b6c672cf3ac97278382 @@ -15,29 +15,6 @@ end return keyid.given_name end --- Everything alice signs is trusted, nothing mallory signs is --- trusted. For certs signed by other people, everything is --- trusted except for one particular cert... --- For use of t_trusted.at. -function get_revision_cert_trust(signers, id, name, val) - for k, v in pairs(signers) do - if v.given_name == "address@hidden" then return true end - if v.given_name == "address@hidden" then return false end - end - if (id == "0000000000000000000000000000000000000000" - and name == "bad-cert" and val == "bad-val") - then return false end - return true -end - -function get_manifest_cert_trust(signers, id, name, val) - return true -end - -function get_file_cert_trust(signers, id, name, val) - return true -end - function accept_testresult_change(old_results, new_results) for test,res in pairs(old_results) do ============================================================ --- tests/trust_hooks_and_trusted_command/__driver__.lua 2ac6428fb5a5564c4f376a4566e041324c8cd88c +++ tests/trust_hooks_and_trusted_command/__driver__.lua 14989f207695c9b6d1c4758d2448f2710d094bca @@ -1,17 +1,24 @@ mtn_setup() mtn_setup() +check(get("hooks.lua")) function trusted(rev, name, value, ...) -- ... is signers - check(mtn("trusted", rev, name, value, ...), 0, true, false) + check(mtn("trusted", "--rcfile", "hooks.lua", rev, name, value, ...), 0, true, false) local t = qgrep(" trusted", "stdout") local u = qgrep(" untrusted", "stdout") or qgrep(" UNtrusted", "stdout") check(t ~= u) return t end -good = string.rep("1", 40) -bad = string.rep("0", 40) +-- create two arbitrary revisions +addfile("goodfile", "good") +commit() +good = base_revision() +addfile("badfile", "bad") +commit() +bad = base_revision() + check(mtn("automate", "genkey", "address@hidden", "address@hidden"), 0, false, false) check(mtn("automate", "genkey", "address@hidden", "address@hidden"), 0, false, false) check(mtn("automate", "genkey", "address@hidden", "address@hidden"), 0, false, false)