# # # patch "rcs_import.cc" # from [63b3cd5118b8a8a249431a0fb4d747130849750c] # to [d97f64868212c2af20979793fd24b5490a98d5c1] # ============================================================ --- rcs_import.cc 63b3cd5118b8a8a249431a0fb4d747130849750c +++ rcs_import.cc d97f64868212c2af20979793fd24b5490a98d5c1 @@ -27,6 +27,9 @@ #include #include +#include +#include + #include "app_state.hh" #include "cert.hh" #include "constants.hh" @@ -1066,7 +1069,42 @@ public: }; +class revision_iterator +{ +private: + cvs_blob_index current_blob; +public: + revision_iterator(void) + : current_blob(0) + {} + + revision_iterator(const revision_iterator & ri) + : current_blob(ri.current_blob) { } + + revision_iterator & operator * (void) + { + return *this; + }; + + revision_iterator & operator = (cvs_blob_index i) + { + L(FL("assigned a value: %d") % i); + current_blob = i; + return *this; + } + + revision_iterator & operator ++ (void) + { + return *this; + } + + revision_iterator & operator ++ (int i) + { + return *this; + }; +}; + // // After stuffing all cvs_events into blobs of events with the same // author and changelog, we have to make sure their dependencies are @@ -1080,6 +1118,12 @@ 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()); + // first split blobs which have events for the same file (i.e. intra-blob // dependencies) for (cvs_blob_index i = 0; i < branch->blobs.size(); ++i) @@ -1106,9 +1150,16 @@ resolve_blob_dependencies(cvs_history &c blob_index_iterator k = branch->get_blob(event->dependency->get_digest(), false); L(FL("blob %d depends on blob %d") % i % k->second); + + add_edge(i, k->second, g); } } } + + // start the topological sort, which calls our revision + // iterator to insert the revisions into our database. + revision_iterator ri; + topological_sort(g, ri); }