# # # patch "mtn_cvs/cvs_sync.cc" # from [25d97022fd848fca9d676932d2b8a89434aa6e6f] # to [ae378289501666399f542f1d9cc5e3fad3007b1f] # # patch "mtn_cvs/cvs_sync.hh" # from [8f758c563e60607d22f4855f7d4259c5ca606653] # to [6bd234f9e025b22dbc88a25ff1f8d23cc3a1a49c] # # patch "mtn_cvs/mtn_automate.cc" # from [99b86dc6eb6d43103e1ba7f710113629f057e522] # to [a6ab1c3dc2c014f07920c83ec3835f2046bb38d6] # # patch "mtn_cvs/mtn_automate.hh" # from [4b8f8ca7d730e343dc365866d3a7e19188b79bf6] # to [2a08d830f55476e94f640324568ebb3f01f631bc] # ============================================================ --- mtn_cvs/cvs_sync.cc 25d97022fd848fca9d676932d2b8a89434aa6e6f +++ mtn_cvs/cvs_sync.cc ae378289501666399f542f1d9cc5e3fad3007b1f @@ -155,11 +155,11 @@ void cvs_repository::parse_cvs_cert_head branch.clear(); mtn_automate::sync_map_t::const_iterator i= value.find(std::make_pair(sp,domain+":root")); - if (i!=value.end()) repository=*i; + if (i!=value.end()) repository=i->second(); i= value.find(std::make_pair(sp,domain+":module")); - if (i!=value.end()) module=*i; + if (i!=value.end()) module=i->second(); i= value.find(std::make_pair(sp,domain+":branch")); - if (i!=value.end()) branch=*i; + if (i!=value.end()) branch=i->second(); } mtn_automate::sync_map_t cvs_repository::create_cvs_cert_header() const @@ -588,35 +588,49 @@ static file_id get_sync_id(mtncvs_state } #endif -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.opts.domain(); - mtn_automate::manifest_map::const_iterator it=oldmanifest.find(file_path_internal(syncname)); - file_id fid; - if (it!=oldmanifest.end()) - fid=app.put_file(state,it->second); - else - fid=app.put_file(state); - static time_t serial; - file_state fs(++serial,""); - fs.size=state.size(); - fs.sha1sum=fid.inner(); - std::pair ires=files[syncname].known_states.insert(fs); - I(ires.second); - e.xfiles[syncname]=ires.first; - return fid; +void cvs_repository::attach_sync_state(cvs_edge & e,mtn_automate::manifest_map const& oldmanifest, + mtn_automate::cset &cs) +{ mtn_automate::sync_map_t state=create_sync_state(e); + for (mtn_automate::sync_map_t::const_iterator i=state.begin(); + i!=state.end(); ++i) + { + mtn_automate::manifest_map::const_iterator f= oldmanifest.find(file_path(i.first)); + if (f==oldmanifest.end()) cs.attrs_set[i->first]=i->second; + else + { + mtn_automate::attr_map_t::const_iterator a=f->second.find(i.first.second); + if (a==f->second.end()) cs.attrs_set[i->first]=i->second; + else if (a->second!=i->second) + { + cs.attrs_cleared.insert(i->first); + cs.attrs_set[i->first]=i->second; + } + } + } + + for (mtn_automate::manifest_map::const_iterator i=oldmanifest.begin(); + i!=oldmanifest.end(); ++i) + { + split_path sp; + i->first.split(sp); + for (mtn_automate::sync_map_t::const_iterator f=state.begin(); f!=state.end(); ++f) + { + if (f->first.first!=sp) continue; + mtn_automate::attr_map_t::const_iterator a=f->first + ??? @@@ delete superfluous attrs + } + } } -std::string cvs_repository::create_sync_state(cvs_edge const& e) +mtn_automate::sync_map_t cvs_repository::create_sync_state(cvs_edge const& e) { std::string state=create_cvs_cert_header(); - state+="#modules\n"; const std::map &sd=GetServerDir(); for (std::map::const_iterator i=sd.begin(); i!=sd.end();++i) - { state+=i->first+"\t"+i->second+"\n"; + { split_path sp; + file_path_internal(i->first).split(sp); + state[std::make_pair(sp,app.opts.domain()+":directory")]=i->second; } - state+="#files\n"; for (cvs_manifest::const_iterator i=e.xfiles.begin(); i!=e.xfiles.end(); ++i) { @@ -624,16 +638,19 @@ std::string cvs_repository::create_sync_ if (i->second->cvs_version.empty()) { W(F("blocking attempt to certify an empty CVS revision\n" "(this is normal for a cvs_takeover of a locally modified tree)\n")); - return std::string(); + return mtn_automate::sync_map_t(); } #else I(!i->second->cvs_version.empty()); #endif - state+=i->second->cvs_version; + split_path sp; + file_path_internal(i->first).split(sp); + state[std::make_pair(sp,app.opts.domain()+":revision")]=i->second->cvs_version; if (!i->second->keyword_substitution.empty()) - state+="/"+i->second->keyword_substitution; + state[std::make_pair(sp,app.opts.domain()+":keyword")]=i->second->keyword_substitution; // FIXME: How to flag locally modified files? add the synched sha1sum? - state+=" "+i->first+"\t"+i->second->sha1sum()+"\n"; + if (!i->second->sha1sum().empty()) + state[std::make_pair(sp,app.opts.domain()+":sha1")]=i->second->sha1sum()/*.substr(0,6)*/; } return state; } @@ -665,8 +682,8 @@ void cvs_repository::commit_cvs2mtn(std: mtn_automate::manifest_map oldmanifest; if (!null_id(parent_rid)) oldmanifest=app.get_manifest_of(parent_rid); - attach_sync_state(const_cast(*e),oldmanifest); build_change_set(*this,oldmanifest,e->xfiles,cs,remove_state); + attach_sync_state(const_cast(*e),oldmanifest,cs); //cs->apply_to(eros); //calculate_ident(new_roster, rev.new_manifest); //safe_insert(rev.edges, std::make_pair(parent_rid, cs)); ============================================================ --- mtn_cvs/cvs_sync.hh 8f758c563e60607d22f4855f7d4259c5ca606653 +++ mtn_cvs/cvs_sync.hh 6bd234f9e025b22dbc88a25ff1f8d23cc3a1a49c @@ -173,7 +173,8 @@ private: void store_modules(); void retrieve_modules(); std::string gather_merge_information(revision_id const& id); -// file_id attach_sync_state(cvs_edge & e,mtn_automate::manifest_map const& oldmanifest); + void attach_sync_state(cvs_edge & e,mtn_automate::manifest_map const& oldmanifest, + mtn_automate::cset &cs); mtn_automate::sync_map_t create_sync_state(cvs_edge const& e); static std::string time_t2human(const time_t &t); ============================================================ --- mtn_cvs/mtn_automate.cc 99b86dc6eb6d43103e1ba7f710113629f057e522 +++ mtn_cvs/mtn_automate.cc a6ab1c3dc2c014f07920c83ec3835f2046bb38d6 @@ -216,7 +216,7 @@ mtn_automate::manifest_map mtn_automate: pa.str(pth); pa.esym(syms::content); pa.hex(content); - result[file_path_internal(pth)]=file_id(content); + result[file_path_internal(pth)].first=file_id(content); } else if (pa.symp(syms::dir)) { @@ -226,6 +226,27 @@ mtn_automate::manifest_map mtn_automate: } else break; + + // Non-dormant attrs + while(pa.symp(basic_io::syms::attr)) + { + pa.sym(); + std::string k, v; + pa.str(k); + pa.str(v); + safe_insert(result[file_path_internal(pth)].second, + make_pair(attr_key(k),attr_value(v))); + } + + // Dormant attrs + while(pa.symp(basic_io::syms::dormant_attr)) + { + pa.sym(); + string k; + pa.str(k); + safe_insert(result[file_path_internal(pth)].second, + make_pair(attr_key(k),attr_value())); + } } return result; } ============================================================ --- mtn_cvs/mtn_automate.hh 4b8f8ca7d730e343dc365866d3a7e19188b79bf6 +++ mtn_cvs/mtn_automate.hh 2a08d830f55476e94f640324568ebb3f01f631bc @@ -19,7 +19,9 @@ struct mtn_automate : mtn_pipe // frontend struct mtn_automate : mtn_pipe -{ typedef std::map manifest_map; // (directories have a null file_id) +{ typedef std::map attr_map_t; + // (directories have a null file_id) + typedef std::map > manifest_map; struct cset { path_set nodes_deleted; @@ -46,11 +48,12 @@ struct mtn_automate : mtn_pipe bool trusted; certificate() : signature(unknown), trusted() {} }; + typedef std::map, attr_value> sync_map_t; +// methods void check_interface_revision(std::string const&minimum); revision_id find_newest_sync(std::string const& domain, std::string const& branch=""); - typedef std::map, attr_value> sync_map_t; sync_map_t get_sync_info(revision_id const& rid, std::string const& domain); void put_sync_info(revision_id const& rid, std::string const& domain, sync_map_t const& data);