# # # patch "ChangeLog" # from [a50f13fec1e9d8414bb18e29f6269c721d037683] # to [ed4b2dd0df28254c08c5b43b81ba9313756970ab] # # patch "rcs_import.cc" # from [2126a8abbdbecc7d57d75e89f03ca875a3bcba67] # to [46889062d97c82d5e490a09bbf3673c7dac57c9d] # ============================================================ --- ChangeLog a50f13fec1e9d8414bb18e29f6269c721d037683 +++ ChangeLog ed4b2dd0df28254c08c5b43b81ba9313756970ab @@ -1,5 +1,13 @@ 2006-04-04 Markus Schiltknecht + * rcs_import.cc: add has_parent_rid and parent_rid + variables to cvs_branch. Import branches with an + associated parent revision first. + And added the branch connecting code from my + previous try to connect branches. + +2006-04-04 Markus Schiltknecht + * rcs_import.cc: modified import order: importing the trunk first, then all branches. This in preparation for branch reconstruction ============================================================ --- rcs_import.cc 2126a8abbdbecc7d57d75e89f03ca875a3bcba67 +++ rcs_import.cc 46889062d97c82d5e490a09bbf3673c7dac57c9d @@ -98,8 +98,10 @@ { bool has_a_branchpoint; bool has_a_commit; + bool has_parent_rid; time_t last_branchpoint; time_t first_commit; + revision_id parent_rid; map live_at_beginning; vector lineage; @@ -107,6 +109,7 @@ cvs_branch() : has_a_branchpoint(false), has_a_commit(false), + has_parent_rid(false), last_branchpoint(0), first_commit(0) { @@ -619,10 +622,12 @@ if (range.first != cvs.branchpoints.end() && range.first->first == curr_version) { + shared_ptr b; + for (ity i = range.first; i != range.second; ++i) { cvs.push_branch(i->second, false); - shared_ptr b = cvs.stk.top(); + b = cvs.stk.top(); if (curr_commit.alive) b->live_at_beginning[cvs.curr_file_interned] = curr_commit.version; b->note_branchpoint(curr_commit.time); @@ -1336,9 +1341,20 @@ map >::const_iterator i; shared_ptr branch; - i = cvs.branches.begin(); - branch = i->second; + // import branches in the correct order + for (i = cvs.branches.begin(); i != cvs.branches.end(); ++i) + { + branch = i->second; + if (branch->has_parent_rid) break; + } + if (i == cvs.branches.end()) + { + L(FL("no more connected branches... unconnected import\n")); + i = cvs.branches.begin(); + branch = i->second; + } + string branchname = i->first; L(FL("branch %s has %d entries\n") % branchname % branch->lineage.size()); @@ -1381,8 +1397,60 @@ n_revisions(n_revs), editable_ros(ros, nis) { - if (!branch.live_at_beginning.empty()) + if (branch.has_parent_rid) { + parent_rid = branch.parent_rid; + app.db.get_roster(parent_rid, ros); + + L(FL("starting cluster for branch %s from revision %s which contains:\n") + % branchname + % branch.parent_rid); + + // populate the cluster_consumer's live_files and created_dirs according + // to the roster. + node_map nodes = ros.all_nodes(); + for (node_map::iterator i = nodes.begin(); i != nodes.end(); ++i) + { + shared_ptr node = i->second; + + if (is_dir_t(node)) + { + split_path dir; + + ros.get_name(node->self, dir); + L(FL(" dir: %s\n") % dir); + safe_insert(created_dirs, dir); + } + else if (is_file_t(node)) + { + std::string rev; + std::string name; + cvs_path path; + split_path sp; + + ros.get_name(node->self, sp); + file_path fp(sp); + path = cvs.path_interner.intern(fp.as_internal()); + + dump(downcast_to_file_t(node)->content, rev); + + L(FL(" file: %s at revision %s\n") % fp.as_internal() % rev); + live_files[path] = cvs.file_version_interner.intern(rev); + } + } + } + + if ((!branch.live_at_beginning.empty()) && ( + /* + * We insert a special 'beginning of branch' commit if we eigther + * have not found a parent revision or... + */ + (!branch.has_parent_rid) || + /* + * ..if we found one, but the branch remained empty. + */ + (branch.has_parent_rid && (!branch.has_a_commit)))) + { cvs_author synthetic_author = cvs.author_interner.intern("cvs_import"); @@ -1568,4 +1636,12 @@ parent_rid = child_rid; } + else if (c.type == ET_BRANCH) + { + /* set the parent revision id of the branch */ +#if 0 + b->parent_rid = parent_rid; + b->has_parent_rid = true; +#endif + } }