# # add_file "tests/t_annotate_branch_collision.at" # # patch "annotate.cc" # from [d593bf9048590b222fd2eb4e6a40775d0d680b07] # to [81e0c5f2c905b3e24fe760199aff1c9d30011051] # # patch "tests/t_annotate_branch_collision.at" # from [] # to [13b7163070c635e0031d6e8b8d18955b2e083618] # # patch "testsuite.at" # from [38f93dd9edbcca5376626c26d83c2105118e02a0] # to [a78806ab60be63d9a18fcc69243595105170221d] # --- annotate.cc +++ annotate.cc @@ -304,7 +304,7 @@ revision_id lastid = nullid; for (size_t i=0; ifile_interned.size()), std::back_inserter(lcs)); - L(F("build_parent_lineage: file_lines.size() == %d, parent.file_lines.size() == %d, lcs.size() == %d\n") - % file_interned.size() % parent_lineage->file_interned.size() % lcs.size()); + //L(F("build_parent_lineage: file_lines.size() == %d, parent.file_lines.size() == %d, lcs.size() == %d\n") + // % file_interned.size() % parent_lineage->file_interned.size() % lcs.size()); // do the copied lines thing for our annotate_context std::vector lcs_src_lines; @@ -372,7 +372,7 @@ size_t i, j; i = j = 0; while (i < file_interned.size() && j < lcs.size()) { - L(F("file_interned[%d]: %ld lcs[%d]: %ld\n") % i % file_interned[i] % j % lcs[j]); + //L(F("file_interned[%d]: %ld lcs[%d]: %ld\n") % i % file_interned[i] % j % lcs[j]); if (file_interned[i] == lcs[j]) { acp->set_copied(mapping[i]); @@ -384,7 +384,7 @@ i++; } - L(F("loop ended with i: %d, j: %d, lcs.size(): %d\n") % i % j % lcs.size()); + //L(F("loop ended with i: %d, j: %d, lcs.size(): %d\n") % i % j % lcs.size()); I(j == lcs.size()); // set touched for the rest of the lines in the file @@ -394,7 +394,7 @@ } // determine the mapping for parent lineage - L(F("build_parent_lineage: building mapping now\n")); + //L(F("build_parent_lineage: building mapping now\n")); i = j = 0; while (i < parent_lineage->file_interned.size() && j < lcs.size()) { if (parent_lineage->file_interned[i] == lcs[j]) { @@ -403,7 +403,7 @@ } else { parent_lineage->mapping[i] = -1; } - L(F("mapping[%d] -> %d\n") % i % parent_lineage->mapping[i]); + //L(F("mapping[%d] -> %d\n") % i % parent_lineage->mapping[i]); i++; } @@ -461,7 +461,7 @@ % *parent % work_unit.node_revision); if (*parent == null_revision) { - // work_unit.node_revision is the root node + // work_unit.node_revision is a root node I(parents.size() == 1); 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); @@ -470,7 +470,7 @@ } // FIX this seems like alot of work to just follow the one file back, write - // dedicated follow_file(child_rev, parent_rev) function + // dedicated follow_file(child_rev, parent_rev) function? change_set cs; calculate_arbitrary_change_set (*parent, work_unit.node_revision, app, cs); if (cs.rearrangement.added_files.find(work_unit.node_fpath) != cs.rearrangement.added_files.end()) { @@ -537,7 +537,10 @@ nodes_to_process.pop_front(); do_annotate_node(work, app, nodes_to_process, nodes_seen); } - I(acp->is_complete()); + //I(acp->is_complete()); + if (!acp->is_complete()) { + W(F("annotate was unable to assign blame to some lines. This is a bug.\n")); + } acp->dump(); //boost::shared_ptr frmt(new annotation_text_formatter()); --- tests/t_annotate_branch_collision.at +++ tests/t_annotate_branch_collision.at @@ -0,0 +1,62 @@ +AT_SETUP([annotate file on multirooted branch]) +MONOTONE_SETUP + +# +# If two people begin a branch with the same name, +# then the branch does not have a unique root. If they +# also happened to both add a file with some shared and +# some differing lines, we must do the right thing. +# + +AT_DATA(foo.left, [z +a +b +x +]) + +AT_DATA(foo.right, [z +j +k +x +]) + +AT_CHECK(cp foo.left foo) +AT_CHECK(MONOTONE add foo, [], [ignore], [ignore]) +COMMIT(testbranch) +REVL=`BASE_REVISION` + +AT_CHECK(rm -r -f MT foo) +AT_CHECK(MONOTONE setup .) + +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]) +REVM=`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 @@ -578,3 +578,4 @@ m4_include(tests/t_multiple_heads_msg.at) m4_include(tests/t_annotate.at) m4_include(tests/t_annotate_add_collision.at) +m4_include(tests/t_annotate_branch_collision.at)