# # # patch "ancestry.cc" # from [3c777fd295ee1ff41231877691411041819fe875] # to [8b3388b690a5f4878bd29d752c3e6e073411739e] # # patch "automate.cc" # from [426f1065c0cadc6c511911ff200c4cd374436c77] # to [a0ff144fedc680631087a881a1876e9bf606d309] # # patch "database.cc" # from [6daec0cdb305150ec3fd37dc9d348230af93da00] # to [026b0f32727c3e31be115a47a4b8de251078151a] # # patch "database.hh" # from [d0f493a74eec8f1514a81fd7abb8c51469dc1205] # to [c7ae2340052b1205f3615f416adb1c58917abfd5] # # patch "database_check.cc" # from [939db552d558905604146370aac78f6b05a6ad6c] # to [55d80d4456c96b241ceabd77be9872cfb7285ab6] # # patch "enumerator.cc" # from [fa0b2faee2460ab510375b0b25badc148b658f56] # to [9e64e9a81b061b38abfcdf0b70e2047e1eb9436f] # # patch "migrate_ancestry.cc" # from [d69ee0d4289d9d1f177dce56032c888a255faaf9] # to [87b81a3b30c9299f5919f8f89b154843a7171989] # ============================================================ --- ancestry.cc 3c777fd295ee1ff41231877691411041819fe875 +++ ancestry.cc 8b3388b690a5f4878bd29d752c3e6e073411739e @@ -84,15 +84,8 @@ find_common_ancestor_for_merge(database multimap inverse_graph; - { - multimap graph; - db.get_revision_ancestry(graph); - typedef multimap::const_iterator gi; - for (gi i = graph.begin(); i != graph.end(); ++i) - inverse_graph.insert(make_pair(i->second, i->first)); - } + db.get_reverse_ancestry(inverse_graph); - while (leaves.size() != 1) { isect->clear(); @@ -313,11 +306,7 @@ erase_ancestors_and_failures(database & inverse_graph_cache_ptr = &inverse_graph; if (inverse_graph_cache_ptr->empty()) { - multimap graph; - db.get_revision_ancestry(graph); - for (multimap::const_iterator i = graph.begin(); - i != graph.end(); ++i) - inverse_graph_cache_ptr->insert(make_pair(i->second, i->first)); + db.get_reverse_ancestry(*inverse_graph_cache_ptr); } // Keep a set of all ancestors that we've traversed -- to avoid @@ -397,12 +386,9 @@ ancestry_difference(database & db, revis { new_stuff.clear(); typedef multimap::const_iterator gi; - multimap graph; multimap inverse_graph; - db.get_revision_ancestry(graph); - for (gi i = graph.begin(); i != graph.end(); ++i) - inverse_graph.insert(make_pair(i->second, i->first)); + db.get_reverse_ancestry(inverse_graph); interner intern; map< ctx, shared_bitmap > ancestors; ============================================================ --- automate.cc 426f1065c0cadc6c511911ff200c4cd374436c77 +++ automate.cc a0ff144fedc680631087a881a1876e9bf606d309 @@ -474,19 +474,19 @@ CMD_AUTOMATE(graph, "", multimap edges_mmap; map > child_to_parents; - db.get_revision_ancestry(edges_mmap); + db.get_reverse_ancestry(edges_mmap); for (multimap::const_iterator i = edges_mmap.begin(); i != edges_mmap.end(); ++i) { - if (child_to_parents.find(i->second) == child_to_parents.end()) - child_to_parents.insert(make_pair(i->second, set())); - if (null_id(i->first)) + if (child_to_parents.find(i->first) == child_to_parents.end()) + child_to_parents.insert(make_pair(i->first, set())); + if (null_id(i->second)) continue; map >::iterator - j = child_to_parents.find(i->second); - I(j->first == i->second); - j->second.insert(i->first); + j = child_to_parents.find(i->first); + I(j->first == i->first); + j->second.insert(i->second); } for (map >::const_iterator ============================================================ --- database.cc 6daec0cdb305150ec3fd37dc9d348230af93da00 +++ database.cc 026b0f32727c3e31be115a47a4b8de251078151a @@ -1111,7 +1111,7 @@ database::info(ostream & out, bool analy L(FL("fetching ancestry map")); typedef multimap::const_iterator gi; rev_ancestry_map graph; - get_revision_ancestry(graph); + get_forward_ancestry(graph); L(FL("checking timestamps differences of related revisions")); int correct = 0, @@ -2461,7 +2461,7 @@ void void -database::get_revision_ancestry(rev_ancestry_map & graph) +database::get_forward_ancestry(rev_ancestry_map & graph) { // share some storage id::symtab id_syms; @@ -2476,6 +2476,21 @@ void } void +database::get_reverse_ancestry(rev_ancestry_map & graph) +{ + // share some storage + id::symtab id_syms; + + results res; + graph.clear(); + imp->fetch(res, 2, any_rows, + query("SELECT child,parent FROM revision_ancestry")); + for (size_t i = 0; i < res.size(); ++i) + graph.insert(make_pair(revision_id(res[i][0], origin::database), + revision_id(res[i][1], origin::database))); +} + +void database::get_revision_parents(revision_id const & id, set & parents) { ============================================================ --- database.hh d0f493a74eec8f1514a81fd7abb8c51469dc1205 +++ database.hh c7ae2340052b1205f3615f416adb1c58917abfd5 @@ -154,7 +154,8 @@ public: // --== The ancestry graph ==-- // public: - void get_revision_ancestry(rev_ancestry_map & graph); + void get_forward_ancestry(rev_ancestry_map & graph); + void get_reverse_ancestry(rev_ancestry_map & graph); void get_revision_parents(revision_id const & ident, std::set & parents); ============================================================ --- database_check.cc 939db552d558905604146370aac78f6b05a6ad6c +++ database_check.cc 55d80d4456c96b241ceabd77be9872cfb7285ab6 @@ -406,7 +406,7 @@ check_ancestry(database & db, { multimap graph; - db.get_revision_ancestry(graph); + db.get_forward_ancestry(graph); L(FL("checking %d ancestry edges") % graph.size()); ticker ticks(_("ancestry"), "a", graph.size()/70+1); @@ -550,7 +550,7 @@ check_heights_relation(database & db, set heights; multimap graph; // parent, child - db.get_revision_ancestry(graph); + db.get_forward_ancestry(graph); L(FL("checking heights for %d edges") % graph.size()); ============================================================ --- enumerator.cc fa0b2faee2460ab510375b0b25badc148b658f56 +++ enumerator.cc 9e64e9a81b061b38abfcdf0b70e2047e1eb9436f @@ -35,12 +35,8 @@ revision_enumerator::revision_enumerator revision_id root; revs.push_back(root); - project.db.get_revision_ancestry(graph); - for (multimap::const_iterator i = graph.begin(); - i != graph.end(); ++i) - { - inverse_graph.insert(make_pair(i->second, i->first)); - } + project.db.get_forward_ancestry(graph); + project.db.get_reverse_ancestry(inverse_graph); } void ============================================================ --- migrate_ancestry.cc d69ee0d4289d9d1f177dce56032c888a255faaf9 +++ migrate_ancestry.cc 87b81a3b30c9299f5919f8f89b154843a7171989 @@ -115,7 +115,7 @@ is_ancestor(database & db, % descendent_id); multimap graph; - db.get_revision_ancestry(graph); + db.get_forward_ancestry(graph); return is_ancestor(ancestor_id, descendent_id, graph); } @@ -911,7 +911,7 @@ build_roster_style_revs_from_manifest_st set all_rev_ids; db.get_revision_ids(all_rev_ids); - db.get_revision_ancestry(existing_graph); + db.get_forward_ancestry(existing_graph); for (multimap::const_iterator i = existing_graph.begin(); i != existing_graph.end(); ++i) { @@ -975,7 +975,7 @@ allrevs_toposorted(database & db, { // get the complete ancestry rev_ancestry_map graph; - db.get_revision_ancestry(graph); + db.get_forward_ancestry(graph); toposort_rev_ancestry(graph, revisions); }