# # # patch "rcs_import.cc" # from [2dec55bff71e2b745f7bc6913cde957a40cd3086] # to [2d7386ad33d634a2e471fa6743500d096cd8caf9] # # patch "tests/importing_cvs_problematic_repo/__driver__.lua" # from [6340ee26326384bd4cff3b58bab4330aa4edc777] # to [3be88b804020af1780642da73ab819f0c392297b] # ============================================================ --- rcs_import.cc 2dec55bff71e2b745f7bc6913cde957a40cd3086 +++ rcs_import.cc 2d7386ad33d634a2e471fa6743500d096cd8caf9 @@ -1058,43 +1058,41 @@ process_one_hunk(vector< piece > const & assert(directive.size() > 1); ++i; - try - { - char code; - int pos, len; - if (sscanf(directive.c_str(), " %c %d %d", &code, &pos, &len) != 3) - throw oops("illformed directive '" + directive + "'"); + 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 - // copy y lines from delta, leaving cursor where it is" - while (cursor < pos) - dest.push_back(source.at(cursor++)); - I(cursor == pos); - while (len--) - dest.push_back(*i++); - } - else if (code == 'd') - { - // 'dx y' means "copy from source to dest until cursor == x-1, - // then increment cursor by y, ignoring those y lines" - while (cursor < (pos - 1)) - dest.push_back(source.at(cursor++)); - I(cursor == pos - 1); - cursor += len; - } - else - throw oops("unknown directive '" + directive + "'"); - } - catch (out_of_range &) - { - throw oops("out_of_range while processing " + directive - + " with source.size() == " - + lexical_cast(source.size()) - + " and cursor == " - + lexical_cast(cursor)); - } + // 'ax y' means "copy from source to dest until cursor == x, then + // copy y lines from delta, leaving cursor where it is" + + // 'dx y' means "copy from source to dest until cursor == x-1, + // then increment cursor by y, ignoring those y lines" + + if (code == 'd') + pos--; + + while (cursor < pos) + try + { + dest.push_back(source.at(cursor++)); + } + catch (out_of_range &) + { + W(F("out of range while processing directive '%s', " + "ignoring %d lines.") % directive % (cursor - pos)); + cursor = pos; + break; + } + + I(cursor == pos); + if (code == 'a') + while (len--) + dest.push_back(*i++); + else if (code == 'd') + cursor += len; + else + throw oops("unknown directive '" + directive + "'"); } static void ============================================================ --- tests/importing_cvs_problematic_repo/__driver__.lua 6340ee26326384bd4cff3b58bab4330aa4edc777 +++ tests/importing_cvs_problematic_repo/__driver__.lua 3be88b804020af1780642da73ab819f0c392297b @@ -10,4 +10,4 @@ check(get("cvs-repository")) -- This rcs file fails to be imported correctly by monotone check(get("cvs-repository")) +check(mtn("--branch=test", "cvs_import", "cvs-repository/test"), 0, false, false) -xfail_if(true, mtn("--branch=test", "cvs_import", "cvs-repository/test"), 0, ignore, ignore)