# # # patch "rcs_import.cc" # from [37597f051b7f8a5b88c0a5e02b565ecfeafcb6fb] # to [a1a7f9b63ab4c0481100bde942c3dc47c540055c] # ============================================================ --- rcs_import.cc 37597f051b7f8a5b88c0a5e02b565ecfeafcb6fb +++ rcs_import.cc a1a7f9b63ab4c0481100bde942c3dc47c540055c @@ -1119,16 +1119,17 @@ cluster_consumer void store_revisions(); }; +template < class MyEdge > struct blob_splitter : public boost::dfs_visitor<> { protected: - bool & _has_cycle; + vector< MyEdge > & back_edges; cvs_branch & branch; public: - blob_splitter(bool & c, cvs_branch & b) - : has_cycle(c), + blob_splitter(cvs_branch & b, vector< MyEdge > & be) + : back_edges(be), branch(b) { } @@ -1142,15 +1143,7 @@ public: void back_edge(Edge e, Graph & g) { L(FL("blob_splitter: back edge: %s") % e); - - if (e->first == e->second) - { - } - else - { - } - - _has_cycle = true; + back_edges.push_back(MyEdge(e.m_source, e.m_target)); } }; @@ -1198,6 +1191,20 @@ public: }; }; +typedef pair< cvs_blob_index, cvs_blob_index > Edge; +typedef boost::adjacency_list< boost::vecS, boost::vecS, + boost::directedS > Graph; + +void +split_blobs_at(shared_ptr const & branch, + const Edge & e, Graph & g) +{ + L(FL("splitting at edge: %d -> %d") % e.first % e.second); + + // TODO + I(false); +} + // // After stuffing all cvs_events into blobs of events with the same // author and changelog, we have to make sure their dependencies are @@ -1212,10 +1219,6 @@ resolve_blob_dependencies(cvs_history &c { L(FL("branch %s currently has %d blobs.") % branchname % branch->blobs.size()); - typedef pair< cvs_blob_index, cvs_blob_index > Edge; - typedef boost::adjacency_list< boost::vecS, boost::vecS, - boost::directedS > Graph; - Graph g(branch->blobs.size()); // fill the graph with all blob dependencies as edges between @@ -1240,11 +1243,16 @@ resolve_blob_dependencies(cvs_history &c } // check for cycles - bool has_cycle = false; - blob_splitter vis(branch, has_cycle); - depth_first_search(g, visitor(vis)); + vector< Edge > back_edges; + blob_splitter< Edge > vis(*branch, back_edges); - I(!has_cycle); + do + { + depth_first_search(g, visitor(vis)); + for (vector< Edge >::const_iterator i = back_edges.begin(); + i != back_edges.end(); ++i) + split_blobs_at(branch, *i, g); + } while (!back_edges.empty()); // start the topological sort, which calls our revision // iterator to insert the revisions into our database.