# # # patch "cmd_othervcs.cc" # from [427bc82909180f87ddae80902a623ad4c3bf01e9] # to [c7af0c1a232457834685a3490007bd64b76eea28] # # patch "rcs_import.cc" # from [ddba992f4f8d785b58ebb6bf94c1919c500ce660] # to [94f78542270de13a70bcb7c7e061734c291b3aa9] # # patch "rcs_import.hh" # from [f425b45c0b8d74290f6b4590aa54203a7257c432] # to [da0eec0d3997cfa177106cbc026806f2f593a061] # ============================================================ --- cmd_othervcs.cc 427bc82909180f87ddae80902a623ad4c3bf01e9 +++ cmd_othervcs.cc c7af0c1a232457834685a3490007bd64b76eea28 @@ -24,12 +24,15 @@ CMD(rcs_import, "rcs_import", "", CMD_RE "You probably want to use cvs_import."), options::opts::branch) { + database db(app); + project_t project(db); + if (args.size() < 1) throw usage(execid); for (args_vector::const_iterator i = args.begin(); i != args.end(); ++i) - test_parse_rcs_file(system_path((*i)())); + test_parse_rcs_file(project, system_path((*i)())); } ============================================================ --- rcs_import.cc ddba992f4f8d785b58ebb6bf94c1919c500ce660 +++ rcs_import.cc 94f78542270de13a70bcb7c7e061734c291b3aa9 @@ -486,6 +486,8 @@ cvs_history struct cvs_history { + project_t & project; + event_pool ev_pool; interner authorclog_interner; @@ -506,6 +508,10 @@ cvs_history // this map is cleared for every RCS file. map branch_first_entries; + // to support successive imports, we keep track of the latest + // imported revision for every branch. + map branch_head_rev; + // event dependency tracking vectors vector dependencies; vector weak_dependencies; @@ -531,8 +537,9 @@ cvs_history // the upper limit of what to import time_t upper_time_limit; - cvs_history(void) - : unnamed_branch_counter(0), + cvs_history(project_t & project) + : project(project), + unnamed_branch_counter(0), step_no(0), deps_sorted(false), upper_time_limit(0) @@ -1603,6 +1610,37 @@ process_rcs_branch(lua_hooks & lua, data file_data curr_data(begin_data), next_data; file_id curr_id(begin_id), next_id; + // Lookup the latest imported revision in this branch. + revision_id head_rev; + if (cvs.branch_head_rev.find(current_branchname) == cvs.branch_head_rev.end()) + { + // FIXME: this doesn't check for CVS certs and instead assumes, the + // branch inserted into only has revisions imported from CVS. + + string branchname = cvs.get_branchname(current_branchname); + set heads; + + // We ignore suspend certs, because otherwise we could possibly fail + // to insert the same revision again. + cvs.project.get_branch_heads(branch_name(branchname), heads, true); + if (!heads.empty()) + { + if (heads.size() > 1) + E(false, F("branch %s has multiple heads") % branchname); + head_rev = *(heads.begin()); + cvs.branch_head_rev.insert(make_pair(current_branchname, head_rev)); + } + } + else + head_rev = cvs.branch_head_rev.find(current_branchname)->second; + + // If this is a successive import, find out what RCS version number this + // file has in that latest imported revision. + if (!null_id(head_rev)) + { + I(false); + } + // a counter for commits which are above our limit. We abort // only after consecutive violations of the limit. int commits_over_time = 0; @@ -1980,9 +2018,9 @@ void } void -test_parse_rcs_file(system_path const & filename) +test_parse_rcs_file(project_t & project, system_path const & filename) { - cvs_history cvs; + cvs_history cvs(project); I(! filename.empty()); assert_path_is_file(filename); @@ -4645,7 +4683,7 @@ import_cvs_repo(options & opts, "try importing a module instead, with 'cvs_import %s/") % cvsroot % cvsroot); - cvs_history cvs; + cvs_history cvs(project); N(opts.branchname() != "", F("need base --branch argument for importing")); if (opts.until_given) @@ -5474,6 +5512,10 @@ blob_consumer::operator()(cvs_blob_index date_t::from_unix_epoch(commit_time), author); + // add the RCS information + put_simple_revision_cert(project.db, keys, new_rid, + cert_name("origin"), cert_value("cvs_import")); + ++n_revisions; } ============================================================ --- rcs_import.hh f425b45c0b8d74290f6b4590aa54203a7257c432 +++ rcs_import.hh da0eec0d3997cfa177106cbc026806f2f593a061 @@ -17,7 +17,7 @@ class branch_name; class project_t; class branch_name; -void test_parse_rcs_file(system_path const & filename); +void test_parse_rcs_file(project_t & project, system_path const & filename); void import_cvs_repo(options & opts, lua_hooks & lua, project_t & project,