# # # add_dir "tests/annotate_ignores_untrusted_certs" # # add_file "tests/annotate_ignores_untrusted_certs/__driver__.lua" # content [dc4cfd5f549e5d23eb2fc7c5e0b6289dab47e42f] # # add_file "tests/annotate_ignores_untrusted_certs/all_untrusted.lua" # content [497aacac10cf6339405dd4d5122a0fe43fb349ef] # # add_file "tests/annotate_ignores_untrusted_certs/author_untrusted.lua" # content [39776e5be8645fe43bae0fa38626ced8200b2811] # # add_file "tests/annotate_ignores_untrusted_certs/date_untrusted.lua" # content [520794fd38ba3d327c40225a05f4f76c92c7b8f3] # # patch "NEWS" # from [a7df42a746e665bfc3bca6dd22f37d44a6813c76] # to [62caab0d8d669bc9326493f45ca101a1230d5bcf] # # patch "annotate.cc" # from [148031d40f893f9a31c9bcc5644e12e5601d5255] # to [626edbf7250b60956a85be3139f7a6d2c2e04580] # ============================================================ --- tests/annotate_ignores_untrusted_certs/__driver__.lua dc4cfd5f549e5d23eb2fc7c5e0b6289dab47e42f +++ tests/annotate_ignores_untrusted_certs/__driver__.lua dc4cfd5f549e5d23eb2fc7c5e0b6289dab47e42f @@ -0,0 +1,20 @@ +-- this is an accompanying test for #30150 + +mtn_setup() +check(get("date_untrusted.lua")) +check(get("author_untrusted.lua")) +check(get("all_untrusted.lua")) + +addfile("foo", "blablabla") +commit() +rev=base_revision() +shortrev=string.sub(rev, 1, 8)..".." + +check(mtn("annotate", "foo", "--rcfile", "date_untrusted.lua"), 0, true, false) +check(qgrep("^" .. shortrev .. " by tester: ", "stdout")) + +check(mtn("annotate", "foo", "--rcfile", "author_untrusted.lua"), 0, true, false) +check(qgrep("^" .. shortrev .. " [0-9]{4}(-[0-9]{2}){2}T[0-9]{2}(:[0-9]{2}){2}: ", "stdout")) + +check(mtn("annotate", "foo", "--rcfile", "all_untrusted.lua"), 0, true, false) +check(qgrep("^" .. shortrev .. ": ", "stdout")) ============================================================ --- tests/annotate_ignores_untrusted_certs/all_untrusted.lua 497aacac10cf6339405dd4d5122a0fe43fb349ef +++ tests/annotate_ignores_untrusted_certs/all_untrusted.lua 497aacac10cf6339405dd4d5122a0fe43fb349ef @@ -0,0 +1,4 @@ +function get_revision_cert_trust(signers, id, name, val) + return false +end + ============================================================ --- tests/annotate_ignores_untrusted_certs/author_untrusted.lua 39776e5be8645fe43bae0fa38626ced8200b2811 +++ tests/annotate_ignores_untrusted_certs/author_untrusted.lua 39776e5be8645fe43bae0fa38626ced8200b2811 @@ -0,0 +1,7 @@ +function get_revision_cert_trust(signers, id, name, val) + if (name == "author") then + return false + end + return true +end + ============================================================ --- tests/annotate_ignores_untrusted_certs/date_untrusted.lua 520794fd38ba3d327c40225a05f4f76c92c7b8f3 +++ tests/annotate_ignores_untrusted_certs/date_untrusted.lua 520794fd38ba3d327c40225a05f4f76c92c7b8f3 @@ -0,0 +1,7 @@ +function get_revision_cert_trust(signers, id, name, val) + if (name == "date") then + return false + end + return true +end + ============================================================ --- NEWS a7df42a746e665bfc3bca6dd22f37d44a6813c76 +++ NEWS 62caab0d8d669bc9326493f45ca101a1230d5bcf @@ -71,6 +71,10 @@ Xxx Xxx 99 99:99:99 UTC 2010 of a revision in which all but one branch have been suspended (fixes monotone bug #29843) + - The annotate command no longer fails if it should print out + empty or untrusted date cert values + (fixes monotone bug #30150) + - monotone now tries harder to find the cancel hint in a commit message and only aborts if it can't find it anywhere (fixes monotone bug #30215) ============================================================ --- annotate.cc 148031d40f893f9a31c9bcc5644e12e5601d5255 +++ annotate.cc 626edbf7250b60956a85be3139f7a6d2c2e04580 @@ -379,7 +379,7 @@ cert_date_value(vector const & cer string const & fmt) { string certval = cert_string_value(certs, name, from_start, from_end, ""); - if (fmt.empty()) + if (fmt.empty() || certval.empty()) return certval; return date_t(certval).as_formatted_localtime(fmt); } @@ -422,10 +422,24 @@ annotate_context::build_revisions_to_ann string date(cert_date_value(certs, date_cert_name, true, false, date_fmt)); string hex_rev_str(encode_hexenc(i->inner()(), i->inner().made_from)); - string result = (F("%s.. by %s %s: ") - % hex_rev_str.substr(0, 8) - % author % date).str(); + string result; + // author and / or date could be empty for two reasons + // a) the specific certs are untrusted by the user, and as such + // got erased earlier from the set + // b) the specific revision does not contain (for whatever reason) + // the needed certificate + // for both reasons we change the output slightly so that no unwanted + // spaces pop up + if (!author.empty() && !date.empty()) + result = (F("%s.. by %s %s: ") % hex_rev_str.substr(0, 8) % author % date).str(); + else if (!author.empty()) + result = (F("%s.. by %s: ") % hex_rev_str.substr(0, 8) % author).str(); + else if (!date.empty()) + result = (F("%s.. %s: ") % hex_rev_str.substr(0, 8) % date).str(); + else + result = (F("%s..: ") % hex_rev_str.substr(0, 8)).str(); + max_note_length = ((result.size() > max_note_length) ? result.size() : max_note_length);