# # patch "cvs_sync.cc" # from [9e2b53b56e10205e1c03878223cdca061ab3a345] # to [0d04b99cba77d577e4b7de8b17180e0829e57259] # ======================================================================== --- cvs_sync.cc 9e2b53b56e10205e1c03878223cdca061ab3a345 +++ cvs_sync.cc 0d04b99cba77d577e4b7de8b17180e0829e57259 @@ -73,13 +73,15 @@ } // whether time is below span or (within span and lesser/equal author,changelog) -bool cvs_sync::operator<=(const file_state &s,const cvs_edge &e) +bool +cvs_sync::operator<=(const file_state &s,const cvs_edge &e) { return s.since_when const & source, +static void +cvs_sync::process_one_hunk(vector< piece > const & source, vector< piece > & dest, vector< piece >::const_iterator & i, int & cursor) @@ -88,12 +90,13 @@ assert(directive.size() > 1); ++i; - char code; - int pos, len; - sscanf(directive.c_str(), " %c %d %d", &code, &pos, &len); - try { + char code; + int pos, len; + if (sscanf(directive.c_str(), " %c %d %d", &code, &pos, &len) != 3) + throw oops("illformed directive '" + directive + "'"); + if (code == 'a') { // 'ax y' means "copy from source to dest until cursor == x, then @@ -318,10 +321,10 @@ { MM(value()); std::string::size_type nlpos=value().find('\n'); - I(nlpos!=std::string::npos); + E(nlpos!=std::string::npos, F("malformed cvs-revision cert %s") % value()); std::string repo=value().substr(0,nlpos); std::string::size_type modulebegin=repo.find('\t'); - I(modulebegin!=std::string::npos); + E(modulebegin!=std::string::npos, F("malformed cvs-revision header %s") % repo); std::string::size_type branchbegin=repo.find(modulebegin,'\t'); std::string::size_type modulelen=std::string::npos; @@ -697,6 +700,18 @@ const_cast(s2->size)=c.contents.size(); contents=c.contents; const_cast(s2->keyword_substitution)=c.keyword_substitution; + } catch (informative_failure &e) + { W(F("Update: patching failed with %s\n") % e.what); + cvs_client::update c=Update(file,s2->cvs_version); + if (c.mod_time!=s2->since_when && c.mod_time!=-1 && s2->since_when!=sync_since) + { W(F("checkout time %ld and log time %ld disagree\n") % c.mod_time % s2->since_when); + } + const_cast(s2->md5sum)=""; + const_cast(s2->patchsize)=0; + store_contents(c.contents, const_cast&>(s2->sha1sum)); + const_cast(s2->size)=c.contents.size(); + contents=c.contents; + const_cast(s2->keyword_substitution)=c.keyword_substitution; } } } @@ -1316,14 +1331,21 @@ bi!=branch_certs.end();++bi) { // actually this finds an arbitrary element of the set intersection if (ci->inner().ident==bi->inner().ident) - { - cvs_repository::parse_cvs_cert_header(*ci,repository,module,branch); - if (branch.empty()) - L(F("using module '%s' in repository '%s'\n") % module % repository); - else - L(F("using branch '%s' of module '%s' in repository '%s'\n") + { try + { cvs_repository::parse_cvs_cert_header(*ci,repository,module,branch); + if (branch.empty()) + L(F("using module '%s' in repository '%s'\n") % module % repository); + else + L(F("using branch '%s' of module '%s' in repository '%s'\n") % branch % module % repository); - goto break_outer; + goto break_outer; + } + catch (std::exception &e) + { W(F("exception %s on revision %s\n") % e.what() % ci->inner().ident); + } + catch (informative_failure &e) + { W(F("exception %s on revision %s\n") % e.what % ci->inner().ident); + } } } break_outer: ; @@ -1629,7 +1651,8 @@ deltas.push_back(current); std::map::iterator>::const_iterator cache_item=revision_lookup.find(current->delta_base); - I(cache_item!=revision_lookup.end()); + E(cache_item!=revision_lookup.end(), + F("missing cvs cert on base revision %s\n") % current->delta_base); current=&*(cache_item->second); } I(current->delta_base.inner()().empty()); @@ -1742,6 +1765,7 @@ try { modtime=cvs_client::Entries2time_t(parts[3]); } catch (std::exception &e) {} + catch (informative_failure &e) {} I(files.find(filename)==files.end()); std::map::iterator f =files.insert(std::make_pair(filename,file_history())).first;