# # patch "cvs_client.hh" # from [465366b05b78273951b96efae16f547af54daa8d] # to [06a54be4dfe382bfa0b4b4121eea9e0001db3e9e] # # patch "cvs_repository.cc" # from [a458d429b24f8d519dfa5df3b78fb4a99aae2d76] # to [1d3087b49057b11f054f15c375d9bfa2e682cd1c] # # patch "cvs_sync.hh" # from [2d02383599596955082db5c3f54ef490582f147c] # to [7db8f1011a1f55d1bf90b5764ef595cb9200e268] # --- cvs_client.hh +++ cvs_client.hh @@ -158,6 +158,8 @@ bool CommandValid(const std::string &cmd) const { return Valid_requests.find(cmd)!=Valid_requests.end(); } void SetServerDir(const std::map &m); + const std::map &GetServerDir() const + { return server_dir; } void drop_connection(); static std::string time_t2rfc822(time_t t); --- cvs_repository.cc +++ cvs_repository.cc @@ -832,7 +832,8 @@ } void cvs_repository::prime() -{ get_all_files(); +{ retrieve_modules(); + get_all_files(); revision_ticker.reset(0); cvs_edges_ticker.reset(new ticker("edges", "E", 10)); for (std::map::iterator i=files.begin();i!=files.end();++i) @@ -896,6 +897,8 @@ // commit them all commit_revisions(edges.begin()); + + store_modules(); } void cvs_repository::cert_cvs(const cvs_edge &e, packet_consumer & pc) @@ -1117,7 +1120,7 @@ } void cvs_repository::commit() -{ +{ retrieve_modules(); std::set::iterator now_iter=last_known_revision(); while (now_iter!=edges.end()) { const cvs_edge &now=*now_iter; @@ -1158,6 +1161,7 @@ // we'd better seperate the commits so that ordering them is possible if (now_iter!=edges.end()) sleep(2); } + store_modules(); } // this is somewhat clumsy ... rethink it @@ -1183,7 +1187,7 @@ I(nlpos!=std::string::npos); std::string repo=value().substr(0,nlpos); std::string::size_type lastslash=repo.find('\t'); -#ifdef BACKWARD:COMPATIBLE +#ifdef BACKWARD_COMPATIBLE if (lastslash==std::string::npos) lastslash=repo.rfind('/'); #endif I(lastslash!=std::string::npos); @@ -1387,7 +1391,8 @@ }; void cvs_repository::update() -{ std::set::iterator now_iter=last_known_revision(); +{ retrieve_modules(); + std::set::iterator now_iter=last_known_revision(); const cvs_edge &now=*now_iter; I(!now.revision().empty()); std::vector file_revisions; @@ -1473,6 +1478,8 @@ // std::cerr << debug(); L(F("%s") % debug()); commit_revisions(dummy_iter); + + store_modules(); } static void apply_manifest_delta(cvs_manifest &base,const cvs_manifest &delta) @@ -1738,6 +1745,8 @@ // update_any_attrs(app); put_revision_id((--edges.end())->revision); // maybe_update_inodeprints(app); + + store_modules(); } // read in directory put into db @@ -1762,3 +1771,38 @@ // 2DO: validate directory to match the structure repo.takeover(); } + +void cvs_repository::store_modules() +{ const std::map &sd=GetServerDir(); + std::string value; + std::string name=host+":"+root+"\t"+module+"\n"; + for (std::map::const_iterator i=sd.begin(); + i!=sd.end();++i) + { value+=i->first+"\t"+i->second+"\n"; + } + std::pair key(var_domain("cvs-server-path"), var_name(name)); + var_value oldval; + app.db.get_var(key,oldval); + if (oldval()!=value) app.db.set_var(key, value); +} + +void cvs_repository::retrieve_modules() +{ if (!GetServerDir().empty()) return; + std::string name=host+":"+root+"\t"+module+"\n"; + std::pair key(var_domain("cvs-server-path"), var_name(name)); + var_value value; + app.db.get_var(key,value); + if (value().empty()) return; + std::map sd; + std::vector pieces; + std::string value_s=value(); + index_deltatext(value_s,pieces); + for (std::vector::const_iterator p=pieces.begin();p!=pieces.end();++p) + { std::string line=**p; + I(!line.empty()); + std::string::size_type tab=line.find('\t'); + I(tab!=std::string::npos); + sd[line.substr(0,tab)]=line.substr(tab+1); + } + SetServerDir(sd); +} --- cvs_sync.hh +++ cvs_sync.hh @@ -149,6 +149,9 @@ struct checkout CheckOut2(const std::string &file, const std::string &revision); void takeover_dir(const std::string &path); + void store_modules(); + void retrieve_modules(); + public: // semi public interface for push/pull void prime(); void update();