# # # patch "cmd_othervcs.cc" # from [cf96c4c5afc724ca199580c188f6f511661e1aba] # to [6334ac3b48a292c1d4e48473f9fbd8b1205dcdfb] # # patch "dates.cc" # from [487b11923395a767fc568429290469ca83a00fc9] # to [8009bace8b1556e98cde789f76d85fb4283aac4e] # # patch "dates.hh" # from [a7f141455c581d29547f76c495cfbac204b0be0d] # to [8f8022b193d72e63734138f61fa3a40cb2a5f9de] # # patch "options_list.hh" # from [185432e32dc44b93821c965cd658d4de5354c1bb] # to [8c139204c81c9dbde9a61bf5b82883f80e28d0df] # # patch "rcs_import.cc" # from [f634395cc25097abb27d48971b930a9e288f08d8] # to [2484c30ee3318af1fe5267a1d041a2863782c610] # ============================================================ --- cmd_othervcs.cc cf96c4c5afc724ca199580c188f6f511661e1aba +++ cmd_othervcs.cc 6334ac3b48a292c1d4e48473f9fbd8b1205dcdfb @@ -34,7 +34,8 @@ CMD(cvs_import, "cvs_import", "", CMD_RE CMD(cvs_import, "cvs_import", "", CMD_REF(rcs), N_("CVSROOT"), N_("Imports all versions in a CVS repository"), "", - options::opts::branch | options::opts::dryrun) + options::opts::branch | options::opts::dryrun | + options::opts::until) { if (args.size() != 1) throw usage(execid); ============================================================ --- dates.cc 487b11923395a767fc568429290469ca83a00fc9 +++ dates.cc 8009bace8b1556e98cde789f76d85fb4283aac4e @@ -331,6 +331,13 @@ date_t::from_string(string const & s) } } +u64 +date_t::as_unix_epoch() const +{ + return 100; +} + + #ifdef BUILD_UNIT_TESTS #include "unit_tests.hh" ============================================================ --- dates.hh a7f141455c581d29547f76c495cfbac204b0be0d +++ dates.hh 8f8022b193d72e63734138f61fa3a40cb2a5f9de @@ -37,6 +37,9 @@ struct date_t // Write out date as a string. std::string const & as_iso_8601_extended() const; + // Write out date as an unsigned 64-bit count of seconds. + u64 as_unix_epoch() const; + private: // For what we do with dates, it is most convenient to store them as // strings in the ISO 8601 extended time format. ============================================================ --- options_list.hh 185432e32dc44b93821c965cd658d4de5354c1bb +++ options_list.hh 8c139204c81c9dbde9a61bf5b82883f80e28d0df @@ -111,6 +111,21 @@ OPT(date, "date", date_t, , } #endif +OPT(until, "until", date_t, , + gettext_noop("maximum date for commits to import")) +#ifdef option_bodies +{ + try + { + date = date_t::from_string(arg); + } + catch (std::exception &e) + { + throw bad_arg_internal(e.what()); + } +} +#endif + GOPT(dbname, "db,d", system_path, , gettext_noop("set name of database")) #ifdef option_bodies { ============================================================ --- rcs_import.cc f634395cc25097abb27d48971b930a9e288f08d8 +++ rcs_import.cc 2484c30ee3318af1fe5267a1d041a2863782c610 @@ -483,12 +483,16 @@ cvs_history bool deps_sorted; + // the upper limit of what to import + time_t upper_time_limit; + cvs_history(void) : n_rcs_revisions(_("RCS revisions"), "r", 1), n_rcs_symbols(_("RCS symbols"), "s", 1), unnamed_branch_counter(0), step_no(0), - deps_sorted(false) + deps_sorted(false), + upper_time_limit(0) { }; void set_filename(string const & file, @@ -1339,6 +1343,10 @@ process_rcs_branch(cvs_symbol_no const & data curr_data(begin_data), next_data; hexenc curr_id(begin_id), next_id; + // a counter for commits which are above our limit. We abort + // only after consecutive violations of the limit. + int commits_over_time = 0; + while(! (r.deltas.find(curr_version) == r.deltas.end())) { curr_events.clear(); @@ -1357,6 +1365,17 @@ process_rcs_branch(cvs_symbol_no const & time_t commit_time = parse_time(delta->second->date.c_str()); I(commit_time > 0); + // Check if we are still within our time limit, if there is one. + // Note that we add six months worth of events, for which we do + // additional processing, but don't use the data afterwards. + if ((cvs.upper_time_limit > 0) && + (commit_time >= cvs.upper_time_limit + (60 * 60 * 24 * 30 * 6))) + { + commits_over_time++; + if (commits_over_time > 1) + break; + } + bool is_synthetic_branch_root = is_sbr(delta->second, deltatext->second); @@ -3717,6 +3736,9 @@ import_cvs_repo(system_path const & cvsr cvs_history cvs; N(app.opts.branchname() != "", F("need base --branch argument for importing")); + if (app.opts.until_given) + cvs.upper_time_limit = app.opts.until.as_unix_epoch(); + // add the trunk branch name string bn = app.opts.branchname(); cvs.base_branch = cvs.symbol_interner.intern(bn);