# # patch "cvs_client.hh" # from [77bd606fc8a6b0a0a66d02907ab9376fc0c67299] # to [465366b05b78273951b96efae16f547af54daa8d] # # patch "cvs_repository.cc" # from [8270d384c6db05c3ff874dcb5e0ff3aa52c5381f] # to [29a5c0c2c36738c30986bd074eb4571544bf84dc] # # patch "cvs_sync.hh" # from [5a27c7c802164da5ffb340e112e8c0e2dc53b1dc] # to [5703c2b158e7c8ae8b17881b60111b75a0f9dad5] # --- cvs_client.hh +++ cvs_client.hh @@ -33,11 +33,15 @@ virtual void revision(const std::string &file,time_t checkin_date, const std::string &rev,const std::string &author, const std::string &state,const std::string &log) const=0; + // to silence gcc + virtual ~rlog_callbacks() {} }; struct rlist_callbacks { virtual void file(const std::string &name, time_t last_change, const std::string &last_rev, bool dead) const=0; + // to silence gcc + virtual ~rlist_callbacks() {} }; struct checkout @@ -52,6 +56,8 @@ }; struct update_callbacks { virtual void operator()(const update &) const=0; + // to silence gcc + virtual ~update_callbacks() {} }; struct update_args { std::string file, old_revision, new_revision, keyword_substitution; --- cvs_repository.cc +++ cvs_repository.cc @@ -12,6 +12,7 @@ #include #include #include +#include using namespace std; @@ -450,9 +451,8 @@ && changelog < other.changelog); } -void cvs_repository::store_contents(const std::string &contents, hexenc &sha1sum) +void cvs_repository::store_contents(const data &dat, hexenc &sha1sum) { - data dat(contents); calculate_ident(dat,sha1sum); if (!app.db.file_version_exists(sha1sum)) { app.db.put_file(sha1sum, dat); @@ -1598,6 +1598,7 @@ N(cvs_Entries.good(), F("can't open %s\n") % (path+"CVS/Entries")); L(F("takeover_dir %s\n") % path); + static hexenc empty_file; while (true) { std::string line; std::getline(cvs_Entries,line); @@ -1638,17 +1639,66 @@ std::map::iterator f =files.insert(std::make_pair(filename,file_history())).first; file_state fs(modtime,parts[2]); - fs.log_msg="initial cvs content"; - fs.author="@@"; + fs.author="?"; fs.keyword_substitution=parts[4]; + { struct stat sbuf; + I(!stat(filename.c_str(), &sbuf)); + if (sbuf.st_mtime!=modtime) + { L(F("modified %s %u %u\n") % filename % modtime % sbuf.st_mtime); + fs.log_msg="partially overwritten content from last update"; + store_contents(std::string(), fs.sha1sum); + f->second.known_states.insert(fs); + + fs.since_when=time(NULL); + fs.cvs_version=std::string(); + } + } // @@ import the file and check whether it is (un-)changed -// fs.sha1sum=@@ + fs.log_msg="initial cvs content"; + data new_data; + read_localized_data(filename, new_data, app.lua); + store_contents(new_data, fs.sha1sum); f->second.known_states.insert(fs); } } } } +void cvs_repository::takeover() +{ + validate_path("",module); + takeover_dir(""); + + bool need_second=false; + cvs_edge e1,e2; + e1.time=0; + e1.changelog="last cvs update (modified)"; + e1.changelog_valid=true; + e2.time=time(NULL); + e2.changelog="cvs takeover"; + e2.changelog_valid=true; + for (std::map::const_iterator i=files.begin(); + i!=files.end();++i) + { cvs_file_state first,second; + first=i->second.known_states.begin(); + I(first!=i->second.known_states.end()); + second=first; + ++second; + if (second==i->second.known_states.end()) second=first; + else if (!need_second) need_second=true; + if (e1.timesince_when) e1.time=first->since_when; + e1.xfiles[i->first]=first; + e2.xfiles[i->first]=second; + // at most two states known ! + I((++second)==i->second.known_states.end()); + } + if (!need_second) e1.changelog=e2.changelog; + edges.insert(e1); + if (need_second) + { edges.insert(e2); + } +} + // read in directory put into db void cvs_sync::takeover(app_state &app) { std::string root,repository; @@ -1666,6 +1716,7 @@ test_key_availability(app); cvs_sync::cvs_repository repo(app,root,repository,false); // 2DO: validate directory to match the structure - repo.validate_path("",repository); - repo.takeover_dir(""); + repo.takeover(); + + std::cerr << repo.debug() << '\n'; } --- cvs_sync.hh +++ cvs_sync.hh @@ -133,7 +133,8 @@ void fill_manifests(std::set::iterator e); void commit_revisions(std::set::iterator e); - void store_contents(const std::string &contents, hexenc &sha1sum); +// std::string is equivalent to data + void store_contents(const data &contents, hexenc &sha1sum); // void apply_delta(std::string &contents, const std::string &patch); void store_delta(const std::string &new_contents, const std::string &old_contents, const std::string &patch, const hexenc &from, hexenc &to); @@ -146,6 +147,7 @@ const cvs_manifest &get_files(const cvs_edge &e); // try harder (reconnect if something goes wrong) struct checkout CheckOut2(const std::string &file, const std::string &revision); + void takeover_dir(const std::string &path); public: // semi public interface for push/pull void prime(); @@ -158,7 +160,7 @@ static time_t posix2time_t(std::string s); - void takeover_dir(const std::string &path); + void takeover(); public: cvs_repository(app_state &app, const std::string &repository, const std::string &module, bool connect=true);