# # # patch "Makefile.am" # from [39cf8705f3a2ef22b0b5cbffff16929edbefeacc] # to [4288915a26cde4c1d982fd494550614fd3a45ba9] # # patch "graph.cc" # from [534420b5361600a2ee78734e4a5fff0d4572c58c] # to [531afa9fac3e9312ed83cc571c6c93da20ca38e3] # # patch "unit-tests/graph.cc" # from [6445249524fa296bd687166581fb8e46ef3494e6] # to [8c39ea6252414a8718ef2c2b099fb0de793e62e0] # ============================================================ --- Makefile.am 39cf8705f3a2ef22b0b5cbffff16929edbefeacc +++ Makefile.am 4288915a26cde4c1d982fd494550614fd3a45ba9 @@ -16,7 +16,7 @@ CMD_SOURCES = \ cmd.hh cmd.cc cmd_netsync.cc cmd_list.cc cmd_packet.cc \ cmd_key_cert.cc cmd_merging.cc cmd_db.cc cmd_diff_log.cc \ cmd_ws_commit.cc cmd_othervcs.cc cmd_automate.cc cmd_files.cc \ - cmd_conflicts.cc + cmd_conflicts.cc cmd_scgi.cc SANITY_CORE_SOURCES = \ sanity.cc sanity.hh quick_alloc.hh vector.hh base.hh \ ============================================================ --- graph.cc 534420b5361600a2ee78734e4a5fff0d4572c58c +++ graph.cc 531afa9fac3e9312ed83cc571c6c93da20ca38e3 @@ -293,7 +293,7 @@ void } void -get_all_ancestors(set const & start, +get_all_ancestors(set const & start, rev_ancestry_map const & child_to_parent_map, set & ancestors) { @@ -313,53 +313,6 @@ get_all_ancestors(set const } } -#ifdef BUILD_UNIT_TESTS - -#include -#include "unit_tests.hh" -#include "randomizer.hh" -#include "roster.hh" - - -static void -get_all_ancestors(revision_id const & start, rev_ancestry_map const & child_to_parent_map, - set & ancestors) -{ - set start_set; - start_set.insert(start); - get_all_ancestors(start, child_to_parent_map, ancestors); -} - -struct mock_rev_graph : rev_graph -{ - mock_rev_graph(rev_ancestry_map const & child_to_parent_map) - : child_to_parent_map(child_to_parent_map) - { - // assign sensible heights - height_map.clear(); - - // toposort expects parent->child - rev_ancestry_map parent_to_child; - for (rev_ancestry_map::const_iterator i = child_to_parent_map.begin(); - i != child_to_parent_map.end(); i++) - { - parent_to_child.insert(make_pair(i->second, i->first)); - } - vector topo_revs; - toposort_rev_ancestry(parent_to_child, topo_revs); - - // this is ugly but works. just give each one a sequential number. - rev_height top = rev_height::root_height(); - u32 num = 1; - for (vector::const_iterator r = topo_revs.begin(); - r != topo_revs.end(); r++, num++) - { - height_map.insert(make_pair(*r, top.child_height(num))); - } - } -} - - // Local Variables: // mode: C++ // fill-column: 76 ============================================================ --- unit-tests/graph.cc 6445249524fa296bd687166581fb8e46ef3494e6 +++ unit-tests/graph.cc 8c39ea6252414a8718ef2c2b099fb0de793e62e0 @@ -139,26 +139,13 @@ UNIT_TEST(random_get_reconstruction_path #include "randomizer.hh" #include "roster.hh" - static void get_all_ancestors(revision_id const & start, rev_ancestry_map const & child_to_parent_map, set & ancestors) { - ancestors.clear(); - vector frontier; - frontier.push_back(start); - while (!frontier.empty()) - { - revision_id rid = frontier.back(); - frontier.pop_back(); - if (ancestors.find(rid) != ancestors.end()) - continue; - safe_insert(ancestors, rid); - typedef rev_ancestry_map::const_iterator ci; - pair range = child_to_parent_map.equal_range(rid); - for (ci i = range.first; i != range.second; ++i) - frontier.push_back(i->second); - } + set start_set; + start_set.insert(start); + get_all_ancestors(start, child_to_parent_map, ancestors); } struct mock_rev_graph : rev_graph