# # patch "commands.cc" # from [d849bf13ddf8928bd8262cf19ba62e582c05712a] # to [932b6305d01d1e0309becc7da957846878012869] # # patch "cvs_repository.cc" # from [29a5c0c2c36738c30986bd074eb4571544bf84dc] # to [c5c5426763415737f5010bd6cf6eb9be377b149c] # # patch "cvs_sync.hh" # from [5703c2b158e7c8ae8b17881b60111b75a0f9dad5] # to [2d02383599596955082db5c3f54ef490582f147c] # --- commands.cc +++ commands.cc @@ -3693,12 +3693,13 @@ } -CMD(cvs_takeover, "working copy", "", +CMD(cvs_takeover, "working copy", "[CVS-MODULE]", "put a CVS working directory under monotone's control", OPT_BRANCH_NAME) { - if (args.size() != 0) throw usage(name); - - cvs_sync::takeover(app); + if (args.size() > 1) throw usage(name); + string module; + if (args.size() == 1) module = idx(args, 0)(); + cvs_sync::takeover(app, module); } --- cvs_repository.cc +++ cvs_repository.cc @@ -1594,7 +1594,13 @@ } void cvs_repository::takeover_dir(const std::string &path) -{ std::ifstream cvs_Entries((path+"CVS/Entries").c_str()); +{ { std::string repository; + std::ifstream cvs_repository((path+"CVS/Repository").c_str()); + N(cvs_repository.good(), F("can't open %sCVS/Repository\n") % path); + std::getline(cvs_repository,repository); + validate_path(path,repository); + } + std::ifstream cvs_Entries((path+"CVS/Entries").c_str()); N(cvs_Entries.good(), F("can't open %s\n") % (path+"CVS/Entries")); L(F("takeover_dir %s\n") % path); @@ -1613,17 +1619,7 @@ continue; } if (parts[0]=="D") - { std::string dirname=parts[1]; - // append dirname - std::string subpath=path+dirname+"/"; - std::string repository; - { ifstream cvs_repository((subpath+"CVS/Repository").c_str()); - N(cvs_repository.good(), - F("can't open %sCVS/Repository\n") % subpath); - std::getline(cvs_repository,repository); - } - validate_path(subpath,repository); - takeover_dir(subpath); + { takeover_dir(path+parts[1]+"/"); } else // file { // remember permissions, store file contents @@ -1665,9 +1661,7 @@ } void cvs_repository::takeover() -{ - validate_path("",module); - takeover_dir(""); +{ takeover_dir(""); bool need_second=false; cvs_edge e1,e2; @@ -1697,26 +1691,29 @@ if (need_second) { edges.insert(e2); } + // commit them all + commit_revisions(edges.begin()); } // read in directory put into db -void cvs_sync::takeover(app_state &app) -{ std::string root,repository; +void cvs_sync::takeover(app_state &app, const std::string &_module) +{ std::string root,module=_module; { fstream cvs_root("CVS/Root"); N(cvs_root.good(), F("can't open ./CVS/Root, please change into the working directory\n")); std::getline(cvs_root,root); } + if (module.empty()) { fstream cvs_repository("CVS/Repository"); N(cvs_repository.good(), F("can't open ./CVS/Repository\n")); - std::getline(cvs_repository,repository); + std::getline(cvs_repository,module); + W(F("Guessing '%s' as the module name\n") % module); } test_key_availability(app); - cvs_sync::cvs_repository repo(app,root,repository,false); + cvs_sync::cvs_repository repo(app,root,module,false); // 2DO: validate directory to match the structure repo.takeover(); - - std::cerr << repo.debug() << '\n'; +// std::cerr << repo.debug() << '\n'; } --- cvs_sync.hh +++ cvs_sync.hh @@ -180,5 +180,5 @@ void push(const std::string &repository, const std::string &module, app_state &app); void admin(const std::string &command, const std::string &arg, app_state &app); -void takeover(app_state &app); +void takeover(app_state &app, const std::string &module); } // end namespace cvs_sync