# # # patch "mtn_cvs/cvs_sync.cc" # from [5739a5ac1828a6b09498ae877742273024ab9144] # to [cb45ce82c1fe72cde7906c3e4af89b139d7b6974] # # patch "mtn_cvs/mtn_automate.cc" # from [e090ae7228ce2c3b752231c4595d5333529d47ab] # to [bcf7a37dd9f31882571737ab2a6d30e5a06258dc] # # patch "mtn_cvs/mtn_automate.hh" # from [a9ab7c98d48c21965fdd7e492f4f8402ce83c6a5] # to [a35ce90bf7b002e3dc50629c3bc8c9563c40163a] # ============================================================ --- mtn_cvs/cvs_sync.cc 5739a5ac1828a6b09498ae877742273024ab9144 +++ mtn_cvs/cvs_sync.cc cb45ce82c1fe72cde7906c3e4af89b139d7b6974 @@ -1130,6 +1130,38 @@ void cvs_repository::commit() void cvs_repository::commit() { retrieve_modules(); + if (edges.empty()) + { // search for a matching start of history + // take first head + std::vector heads=app.heads(app.opts.branch_name()); + N(!heads.empty(), F("branch %s has no heads") % app.opts.branch_name()); + + revision_id actual=*heads.begin(); + is_branch branch_comparer(app.opts.branch_name()); + do + { std::vector parents=app.get_revision_parents(actual); + for (std::vector::const_iterator i=parents.begin(); + i!=parents.end();++i) + { if (*i==revision_id()) break; // root revision + std::vector certs + = app.get_revision_certs(*i); + for (std::vector::const_iterator j=certs.begin(); + j!=certs.end();++j) + if (branch_comparer(*j)) + { actual=*i; + goto continue_outer; + } + } + continue_outer: ; + } while (true); + // start with actual + I(!null_id(actual)); + bool fail=false; +// commit_mtn2cvs(edges.end(), actual, fail); +// automate::manifest_map root_manifest=app.get_manifest_of(actual); + + I(!fail); + } std::set::iterator now_iter=last_known_revision(); while (now_iter!=edges.end()) { const cvs_edge &now=*now_iter; @@ -1221,7 +1253,8 @@ void cvs_sync::push(const std::string &_ std::string const& _branch, mtncvs_state &app) { cvs_repository *repo=cvs_sync::prepare_sync(_repository,_module,_branch,app); - N(!repo->empty(),F("no revision certs for this repository/module\n")); + if (repo->empty()) + W(F("no revision certs for this module, exporting all\n")); L(FL("push")); // std::cerr << repo->debug() << '\n'; repo->commit(); ============================================================ --- mtn_cvs/mtn_automate.cc e090ae7228ce2c3b752231c4595d5333529d47ab +++ mtn_cvs/mtn_automate.cc bcf7a37dd9f31882571737ab2a6d30e5a06258dc @@ -155,6 +155,19 @@ std::vector mtn_automate::g return result; } +std::vector mtn_automate::heads(std::string const& branch) +{ std::vector args(1,branch); + std::string heads=automate("heads",args); + std::vector result; + piece::piece_table lines; + piece::index_deltatext(heads,lines); + result.reserve(children.size()); + for (piece::piece_table::const_iterator p=lines.begin();p!=lines.end();++p) + result.push_back(revision_id((**p).substr(0,constants::idlen))); + piece::reset(); + return result; +} + static void print_cset(basic_io::printer &printer, mtn_automate::cset const& cs) { for (path_set::const_iterator i = cs.nodes_deleted.begin(); i != cs.nodes_deleted.end(); ++i) ============================================================ --- mtn_cvs/mtn_automate.hh a9ab7c98d48c21965fdd7e492f4f8402ce83c6a5 +++ mtn_cvs/mtn_automate.hh a35ce90bf7b002e3dc50629c3bc8c9563c40163a @@ -66,6 +66,7 @@ struct mtn_automate : mtn_pipe std::vector get_revision_children(revision_id const& rid); std::vector get_revision_parents(revision_id const& rid); revision_t get_revision(revision_id const& rid); + std::vector heads(std::string const& branch); std::string get_option(std::string const& name); };