# # # patch "mtn_cvs/cvs_sync.cc" # from [7f4e7cfef32fbb6a4d8861555e9fb357cb42b3ce] # to [94dabfec451c45fd97cf1f9d488ee86113ca1d74] # # patch "mtn_cvs/mtn_cvs.cc" # from [03d9034c943e682f87d545eda52f763a5b11b03f] # to [afe34352c504140e1a5a5f7bccf2d25e5f9fa745] # # patch "mtn_cvs/mtncvs_state.cc" # from [adca565befa22809d3df5c0a9f16f79ecb5a330b] # to [79a1b44a8208a8adb1e22b7612fa83a1c4dd235e] # # patch "mtn_cvs/mtncvs_state.hh" # from [3e366f3dcffa1252a31946e75f091d6cd630fa0c] # to [ef506fb70c8052e6ee483eeff443a27203962d39] # # patch "mtn_cvs/options_list.hh" # from [b5cff95686fc6317318e75b74ac7fcc2a3f6da0b] # to [a27b04c31de840bfb62ce90d1b88d0277deb6476] # ============================================================ --- mtn_cvs/cvs_sync.cc 7f4e7cfef32fbb6a4d8861555e9fb357cb42b3ce +++ mtn_cvs/cvs_sync.cc 94dabfec451c45fd97cf1f9d488ee86113ca1d74 @@ -583,13 +583,13 @@ static file_id get_sync_id(mtncvs_state static file_id get_sync_id(mtncvs_state &app, revision_id id) { mtn_automate::manifest_map m=app.get_manifest_of(id); - return m[file_path_internal(".mtn-sync-"+app.domain())]; + return m[file_path_internal(".mtn-sync-"+app.opts.domain())]; } file_id cvs_repository::attach_sync_state(cvs_edge & e,mtn_automate::manifest_map const& oldmanifest) { std::string state=create_sync_state(e); if (state.empty()) return file_id(); // locally changed CVS tree state - std::string syncname=".mtn-sync-"+app.domain(); + std::string syncname=".mtn-sync-"+app.opts.domain(); mtn_automate::manifest_map::const_iterator it=oldmanifest.find(file_path_internal(syncname)); file_id fid; if (it!=oldmanifest.end()) @@ -691,7 +691,7 @@ void cvs_repository::commit_cvs2mtn(std: L(FL("CVS Sync: Inserted revision %s into repository\n") % child_rid); e->revision=child_rid.inner(); - app.cert_revision(child_rid,"branch",app.branch()); + app.cert_revision(child_rid,"branch",app.opts.branch_name()); std::string author=e->author; if (author.find('@')==std::string::npos) author+="@"+host; app.cert_revision(child_rid, "author", author); @@ -803,8 +803,8 @@ cvs_repository::cvs_repository(mtncvs_st { file_id_ticker.reset(new ticker("file ids", "F", 10)); remove_state=remove_set.insert(file_state(0,"-",true)).first; - if (!app.since().empty()) - { sync_since=posix2time_t(app.since()); + if (!app.opts.since().empty()) + { sync_since=posix2time_t(app.opts.since()); N(sync_since<=time(0), F("Since lies in the future. Remember to specify time in UTC\n")); } } @@ -857,7 +857,7 @@ std::set::iterator cvs_reposit { commit_arg a; a.file=file_path(*i).as_internal(); cvs_manifest::const_iterator old=parent_manifest.find(a.file); - if (a.file==".mtn-sync-"+app.domain()) continue; + if (a.file==".mtn-sync-"+app.opts.domain()) continue; I(old!=parent_manifest.end()); a.removed=true; a.old_revision=old->second->cvs_version; @@ -900,7 +900,7 @@ std::set::iterator cvs_reposit { commit_arg a; a.file=file_path(i->first).as_internal(); - if (a.file==".mtn-sync-"+app.domain()) continue; + if (a.file==".mtn-sync-"+app.opts.domain()) continue; a.new_content=app.get_file(i->second); commits.push_back(a); L(FL("add %s %d\n") % a.file % a.new_content.size()); @@ -912,7 +912,7 @@ std::set::iterator cvs_reposit { commit_arg a; a.file=file_path(i->first).as_internal(); - if (a.file==".mtn-sync-"+app.domain()) continue; + if (a.file==".mtn-sync-"+app.opts.domain()) continue; cvs_manifest::const_iterator old=parent_manifest.find(a.file); I(old!=parent_manifest.end()); a.old_revision=old->second->cvs_version; @@ -1004,7 +1004,7 @@ std::string cvs_repository::gather_merge // this revision is already in _this_ repository // TODO: has sync info would be sufficient try - { if (!app.get_sync_info(*i,app.domain()).empty()) continue; + { if (!app.get_sync_info(*i,app.opts.domain()).empty()) continue; } catch (std::exception &e) { W(F("get sync info threw %s") % e.what()); } @@ -1056,14 +1056,14 @@ void cvs_repository::commit() L(FL("looking for children of revision %s\n") % now.revision); std::vector children=app.get_revision_children(now.revision); - if (!app.branch().empty()) - { // app.branch + if (!app.opts.branch_name().empty()) + { // app.opts.branch_name // ignore revisions not belonging to the specified branch for (std::vector::iterator i=children.begin(); i!=children.end();) { std::vector certs = app.get_revision_certs(*i); - if (std::remove_if(certs.begin(),certs.end(),is_branch(app.branch()))==certs.begin()) + if (std::remove_if(certs.begin(),certs.end(),is_branch(app.opts.branch_name()))==certs.begin()) i=children.erase(i); else ++i; } @@ -1071,8 +1071,8 @@ void cvs_repository::commit() if (children.empty()) return; revision_id next; if (children.size()>1) // && !ap.revision_selectors.size()) - { for (std::vector::const_iterator i=app.revisions.begin(); - i!=app.revisions.end();++i) + { for (std::vector::const_iterator i=app.opts.revisions.begin(); + i!=app.opts.revisions.end();++i) { for (std::vector::const_iterator j=children.begin(); j!=children.end();++j) { if (*i==*j) @@ -1108,14 +1108,14 @@ static void guess_repository(std::string static void guess_repository(std::string &repository, std::string &module, std::string & branch,std::string &last_state, revision_id &lastid, mtncvs_state &app) -{ I(!app.branch().empty()); +{ I(!app.opts.branch_name().empty()); try - { lastid=app.find_newest_sync(app.domain(),app.branch()); + { lastid=app.find_newest_sync(app.opts.domain(),app.opts.branch_name()); if (null_id(lastid)) - { L(FL("no sync information found on branch %s\n")%app.branch()); + { L(FL("no sync information found on branch %s\n")%app.opts.branch_name()); return; } - last_state=app.get_sync_info(lastid,app.domain()); + last_state=app.get_sync_info(lastid,app.opts.domain()); cvs_repository::parse_cvs_cert_header(last_state,repository,module,branch); if (branch.empty()) L(FL("using module '%s' in repository '%s'\n") % module % repository); @@ -1125,7 +1125,7 @@ static void guess_repository(std::string } catch (std::runtime_error) { N(false, F("can not guess repository (in domain %s), " - "please specify on first pull") % app.domain); + "please specify on first pull") % app.opts.domain); } } @@ -1662,12 +1662,12 @@ void cvs_repository::takeover() // now we initialize the workspace // mtn setup . { std::vector args; - args.push_back(app.mtn_binary()); + args.push_back(app.opts.mtn_binary()); if (args[0].empty()) args[0]="mtn"; - for (std::vector::const_iterator i=app.mtn_options.begin();i!=app.mtn_options.end();++i) + for (std::vector::const_iterator i=app.opts.mtn_options.begin();i!=app.opts.mtn_options.end();++i) args.push_back((*i)()); args.push_back("--branch"); - args.push_back(app.branch()); + args.push_back(app.opts.branch_name()); args.push_back("setup"); args.push_back("."); I(args.size()<30); @@ -1756,5 +1756,5 @@ void cvs_repository::cert_cvs(cvs_edge c // we could pass delta_base and forget about it later void cvs_repository::cert_cvs(cvs_edge const& e) { std::string content=create_sync_state(e); - app.put_sync_info(e.revision,app.domain(),content); + app.put_sync_info(e.revision,app.opts.domain(),content); } ============================================================ --- mtn_cvs/mtn_cvs.cc 03d9034c943e682f87d545eda52f763a5b11b03f +++ mtn_cvs/mtn_cvs.cc afe34352c504140e1a5a5f7bccf2d25e5f9fa745 @@ -107,7 +107,7 @@ CMD(pull, N_("network"), N_("[CVS-REPOSI } mtncvs_state &myapp=mtncvs_state::upcast(app); //myapp.dump(); - N(!myapp.branch().empty(), F("no destination branch specified\n")); + N(!myapp.opts.branch_name().empty(), F("no destination branch specified\n")); cvs_sync::pull(repository,module,branch,myapp); } @@ -137,7 +137,7 @@ CMD(takeover, N_("working copy"), N_("[C std::string module; if (args.size() == 1) module = idx(args, 0)(); mtncvs_state &myapp=mtncvs_state::upcast(app); - N(!myapp.branch().empty(), F("no destination branch specified\n")); + N(!myapp.opts.branch_name().empty(), F("no destination branch specified\n")); cvs_sync::takeover(myapp, module); } ============================================================ --- mtn_cvs/mtncvs_state.cc adca565befa22809d3df5c0a9f16f79ecb5a330b +++ mtn_cvs/mtncvs_state.cc 79a1b44a8208a8adb1e22b7612fa83a1c4dd235e @@ -18,18 +18,18 @@ void mtncvs_state::dump() } void mtncvs_state::dump() -{ std::cerr D(full) D(since) D(mtn_binary) D(branch) << '\n'; - std::cerr D(mtn_options) << '\n'; +{ std::cerr D(opts.full) D(opts.since) D(opts.mtn_binary) D(opts.branch_name) << '\n'; + std::cerr D(opts.mtn_options) << '\n'; } void mtncvs_state::open() { std::vector args; - for (std::vector::const_iterator i=mtn_options.begin();i!=mtn_options.end();++i) + for (std::vector::const_iterator i=opts.mtn_options.begin();i!=opts.mtn_options.end();++i) args.push_back((*i)()); - std::string binary=mtn_binary(); + std::string binary=opts.mtn_binary(); if (binary.empty()) binary="mtn"; I(!is_open()); L(FL("mtncvs_state: opening mtn binary %s") % binary); mtn_automate::open(binary,args); - check_interface_revision("3.3"); + check_interface_revision("4.1"); } ============================================================ --- mtn_cvs/mtncvs_state.hh 3e366f3dcffa1252a31946e75f091d6cd630fa0c +++ mtn_cvs/mtncvs_state.hh ef506fb70c8052e6ee483eeff443a27203962d39 @@ -10,22 +10,22 @@ // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. - +#include "options.hh" #include #include struct mtncvs_state : private app_state, public mtn_automate -{ bool full; +{ /*bool full; utf8 since; std::vector revisions; utf8 mtn_binary; std::vector mtn_options; utf8 branch; - utf8 domain; + utf8 domain; */ options opts; - mtncvs_state() : full(), mtn_binary("mtn"), domain("cvs") {} +// mtncvs_state() : full(), mtn_binary("mtn"), domain("cvs") {} // to access the private base class (only to pass it around) app_state& downcast() { return *this; } ============================================================ --- mtn_cvs/options_list.hh b5cff95686fc6317318e75b74ac7fcc2a3f6da0b +++ mtn_cvs/options_list.hh a27b04c31de840bfb62ce90d1b88d0277deb6476 @@ -18,10 +18,10 @@ OPTION(branch, branch, true, "branch,b", } #endif -OPT(since, "since", bool, false, N_("set history start for CVS pull")) +OPT(since, "since", utf8, , N_("set history start for CVS pull")) #ifdef option_bodies { - since = true; + since = arg; } #endif @@ -64,16 +64,62 @@ OPTION(globals, debug, false, "debug", } #endif -GOPT(mtn, "mtn", std::string, , gettext_noop("monotone binary name")) +GOPT(mtn_binary, "mtn", utf8, , gettext_noop("monotone binary name")) #ifdef option_bodies { - mtn = arg; + mtn_binary = arg; } #endif +GOPT(domain, "domain", utf8, "cvs", gettext_noop("synchronization domain")) +#ifdef option_bodies +{ + domain = arg; +} +#endif + +OPTVAR(globals, std::vector, mtn_options, ) +OPTION(globals, mtn_option, true, "mtn-option", N_("pass option to monotone")) +#ifdef option_bodies +{ + mtn_options.push_back(arg); +} +#endif + +#define TRANSOPT_sub(name,hasarg,optstring,desc) \ + OPTION(globals,name,hasarg,optstring,desc) + +#ifdef option_bodies +#define TRANSOPT3(name,optstring,desc) TRANSOPT_sub(name,true,optstring,desc) \ +{ mtn_options.push_back("--" #name "=" +arg); } +#else +#define TRANSOPT3(name,optstring,desc) TRANSOPT_sub(name,true,optstring,desc) +#endif + +#define TRANSOPT(name,desc) TRANSOPT3(name,#name,desc) + +#ifdef option_bodies +#define TRANSOPT_BOOL(name,desc) TRANSOPT_sub(name,false,#name,desc) \ +{ mtn_options.push_back(utf8("--" #name)); } +#else +#define TRANSOPT_BOOL(name,desc) TRANSOPT_sub(name,false,#name,desc) +#endif + +// these options are passed transparently +TRANSOPT3(db, "db,d", N_("passed: database location")); +TRANSOPT(rcfile, N_("passed: config file")); +TRANSOPT_BOOL(nostd, N_("passed: do not read standard hooks")); +TRANSOPT(keydir, N_("passed: key directory")); +TRANSOPT3(key, "key,k", N_("passed: key")); +TRANSOPT_BOOL(norc, N_("passed: norc")); +TRANSOPT(root, N_("passed: root")); +TRANSOPT(confdir, N_("passed: confdir")); + +#undef TRANSOPT3 +#undef TRANSOPT_BOOL +#undef TRANSOPT + #if 0 -GOPT(mtn_option, "mtn-option", string, N_("pass option to monotone")); -// these options are passed transparently GOPT(db, "db,d", string, N_("passed: database location")); GOPT(rcfile, "rcfile", string, N_("passed: config file")); GOPT(nostd, "nostd", nil, N_("passed: do not read standard hooks"));