# # add_file "tests/t_annotate_add_collision.at" # # patch "annotate.cc" # from [68acf41a4377caa428e893e9f3aba6d4311f7ae0] # to [d593bf9048590b222fd2eb4e6a40775d0d680b07] # # patch "tests/t_annotate.at" # from [5e785755c0a1c42517ef9dbe9836ca5e20d660a2] # to [a58f8b496e57f594a0c8c7a7f8ac146ddbea1996] # # patch "tests/t_annotate_add_collision.at" # from [] # to [bc6cec77fe817f77889b7dd79c1a8c68a4b46796] # # patch "testsuite.at" # from [26d537a5cb0f97ef7951da274520599d3b22d86b] # to [38f93dd9edbcca5376626c26d83c2105118e02a0] # --- annotate.cc +++ annotate.cc @@ -96,9 +96,6 @@ void set_copied(int index); void set_touched(int index); - void set_root_revision(revision_id rev) { root_revision = rev; } - revision_id get_root_revision() const { return root_revision; } - /// return an immutable reference to our vector of string data for external use const std::vector& get_file_lines() const; @@ -140,6 +137,8 @@ boost::shared_ptr build_parent_lineage(boost::shared_ptr acp, revision_id parent_rev, const file_data &parent_data) const; + void credit_mapped_lines (boost::shared_ptr acp) const; + private: void init_with_lines(const std::vector &lines); @@ -339,8 +338,6 @@ mapping.clear(); mapping.reserve(lines.size()); - //interner in; - int count; std::vector::const_iterator i; for (count=0, i = lines.begin(); i != lines.end(); i++, count++) { @@ -416,6 +413,16 @@ } +void +annotate_lineage_mapping::credit_mapped_lines (boost::shared_ptr acp) const +{ + std::vector::const_iterator i; + for (i=mapping.begin(); i != mapping.end(); i++) { + acp->set_touched(*i); + } +} + + static file_id find_file_id_in_revision(app_state &app, file_path fpath, revision_id rid) { @@ -430,6 +437,7 @@ return fid; } + static void do_annotate_node (const annotate_node_work &work_unit, app_state &app, @@ -455,8 +463,9 @@ if (*parent == null_revision) { // work_unit.node_revision is the root node I(parents.size() == 1); - L(F("do_annotate_node setting root revision as %s\n") % work_unit.node_revision); - work_unit.annotations->set_root_revision(work_unit.node_revision); + L(F("do_annotate_node credit_mapped_lines to revision %s\n") % work_unit.node_revision); + work_unit.lineage->credit_mapped_lines(work_unit.annotations); + work_unit.annotations->evaluate(work_unit.node_revision); return; } @@ -499,13 +508,10 @@ I(added_in_parent_count >= 0); I((size_t)added_in_parent_count <= parents.size()); - if (added_in_parent_count == parents.size()) { - N(parents.size() == 1, - F("annotate is confused by one file added on separate branches or forks of a branch\n")); - L(F("added_in_parent_count == parents.size(), set_root_revision %s\n") + if ((size_t)added_in_parent_count == parents.size()) { + L(F("added_in_parent_count == parents.size(), credit_mapped_lines to %s\n") % work_unit.node_revision); - work_unit.annotations->set_root_revision(work_unit.node_revision); - return; + work_unit.lineage->credit_mapped_lines(work_unit.annotations); } work_unit.annotations->evaluate(work_unit.node_revision); @@ -531,12 +537,7 @@ nodes_to_process.pop_front(); do_annotate_node(work, app, nodes_to_process, nodes_seen); } - if (!acp->is_complete()) { - L(F("do_annotate acp remains incomplete after processing all nodes\n")); - revision_id null_revision; - I(!(acp->get_root_revision() == null_revision)); - acp->complete(acp->get_root_revision()); - } + I(acp->is_complete()); acp->dump(); //boost::shared_ptr frmt(new annotation_text_formatter()); --- tests/t_annotate.at +++ tests/t_annotate.at @@ -96,7 +96,6 @@ # Try add of file on one side of branch # - # Making left side of fork, we won't add the file here AT_DATA(foo0, [foo now has other data --- tests/t_annotate_add_collision.at +++ tests/t_annotate_add_collision.at @@ -0,0 +1,61 @@ +AT_SETUP([annotate file added on different forks]) +MONOTONE_SETUP + +AT_DATA(foo.left, [z +a +b +x +]) + +AT_DATA(foo.right, [z +j +k +x +]) + +ADD_FILE(initialfile, [a +b +c +]) +COMMIT(testbranch) +REV0=`BASE_REVISION` + + +AT_CHECK(cp foo.left foo) +AT_CHECK(MONOTONE add foo, [], [ignore], [ignore]) +COMMIT(testbranch) +REVL=`BASE_REVISION` + +REVERT_TO($REV0) +AT_CHECK(cp foo.right foo) +AT_CHECK(MONOTONE add foo, [], [ignore], [ignore]) +COMMIT(testbranch) +REVR=`BASE_REVISION` + +AT_DATA(merge2.lua, [ +function merge2 (left, right) + data = "z\na\nk\nx\n" + return data +end +]) + +AT_CHECK(MONOTONE --rcfile=merge2.lua merge, [], [ignore], [ignore]) +AT_CHECK(MONOTONE update, [], [ignore], [ignore]) +REV1=`BASE_REVISION` + +# +# annotate foo should now be +# REVC: z +# REVL: a +# REVR: k +# REVC: x +# +# where REVC (choice) is either REVL or REVR + +AT_CHECK(MONOTONE annotate foo, [], [stdout], [ignore]) +#AT_CHECK(head -n 1 stdout | grep $REV1, [0], [ignore], [ignore]) +AT_CHECK(head -n 2 stdout | tail -n 1 | grep $REVL, [0], [ignore], [ignore]) +AT_CHECK(head -n 3 stdout | tail -n 1 | grep $REVR, [0], [ignore], [ignore]) +#AT_CHECK(head -n 4 stdout | tail -n 1 | grep $REV1, [0], [ignore], [ignore]) + +AT_CLEANUP --- testsuite.at +++ testsuite.at @@ -577,3 +577,4 @@ m4_include(tests/t_bad_packets.at) m4_include(tests/t_multiple_heads_msg.at) m4_include(tests/t_annotate.at) +m4_include(tests/t_annotate_add_collision.at)