# # # add_dir "mtn_cvs/tests/takeover_basic" # # add_file "mtn_cvs/tests/takeover_basic/__driver__.lua" # content [9c9b09598a2863407d1fe73677496fd290cc5cbd] # # patch "automate.cc" # from [2642bb1e7be9e55ec7c4df32c97252c92b150ada] # to [8185bfd56f8f3a08accb449fc3d87bd40fb57fba] # # patch "mtn_cvs/cvs_sync.cc" # from [0673b89d59fffdd5d6b6d0c092eab6bb5c4f6e77] # to [7630300ef708983a0f5545a9451ac3ac306f3759] # # patch "mtn_cvs/testsuite.lua" # from [8339314159b3c522337e0d3b6c0fb60e5ba36d70] # to [fba339f4b18d305e89fb9b1aa7e8e8c4902f5ee4] # ============================================================ --- mtn_cvs/tests/takeover_basic/__driver__.lua 9c9b09598a2863407d1fe73677496fd290cc5cbd +++ mtn_cvs/tests/takeover_basic/__driver__.lua 9c9b09598a2863407d1fe73677496fd290cc5cbd @@ -0,0 +1,47 @@ +-- take over a modified CVS checkout and push changes into CVS + +include("/common/cvs.lua") +mtn_setup() +cvs_setup() + +mkdir("cvstemp") +writefile("cvstemp/A", "initial import\n") +tsha0 = sha1("cvstemp/A") +check(indir("cvstemp", cvs("import", "-m", "import", "test", "vtag", "rtag")), 0, false, false) +remove("cvstemp") + +-- change the repository in various ways + +check(cvs("co", "test"), 0, false, false) +writefile("test/B", "file added\n") +tsha1 = sha1("test/B") +check(indir("test", cvs("add", "B")), 0, false, false) +os.execute("sleep 1") +check(indir("test", cvs("ci", "-m", "B added")), 0, false, false) + +check(indir("test", cvs("delete","-f","A")), 0,false,false) +os.execute("sleep 1") +check(indir("test", cvs("ci", "-m", "A removed")), 0, false, false) + +-- we need the root option to not look for a _MTN directory above the test +check(indir("test",mtn_cvs("--root=.", "--branch=testbranch", "takeover", "test")), 0, false, false) + +writefile("test/B", "something different\n") +tsha2 = sha1("test/B") + +check(indir("test", mtn("ci","-m","B changed")), 0, false, false) + +check(mtn_cvs("--branch=testbranch","push"), 0, false, false) + +--------------- +-- check presence of files + +check(mtn("automate", "get_file", tsha2), 0, false) + +-- also check that CVS sees this newly changed file + +-- FIXME: win32 +os.execute("mv test test.old") + +check(cvs("co", "test"), 0, false, false) +check(sha1("test/B") == tsha2) ============================================================ --- automate.cc 2642bb1e7be9e55ec7c4df32c97252c92b150ada +++ automate.cc 8185bfd56f8f3a08accb449fc3d87bd40fb57fba @@ -1692,10 +1692,15 @@ AUTOMATE(put_revision, N_("SINGLE-EDGE-D revision_id id; calculate_ident(rev, id); - transaction_guard tr(app.db); - rev.made_for=made_for_database; - app.db.put_revision(id, rev); - tr.commit(); + if (app.db.revision_exists(id)) + W(F("revision %s already present in the database") % id); + else + { + transaction_guard tr(app.db); + rev.made_for=made_for_database; + app.db.put_revision(id, rev); + tr.commit(); + } output << id; } ============================================================ --- mtn_cvs/cvs_sync.cc 0673b89d59fffdd5d6b6d0c092eab6bb5c4f6e77 +++ mtn_cvs/cvs_sync.cc 7630300ef708983a0f5545a9451ac3ac306f3759 @@ -1778,8 +1778,17 @@ void cvs_repository::takeover() process_spawn(argv); } { ofstream of("_MTN/revision"); + if (!of.good()) + { + W(F("_MTN/revision still busy?")); + sleep(1); + of.open("_MTN/revision",std::ios_base::out|std::ios_base::trunc); + } + I(of.good()); + I(!edges.empty()); + I(!(--edges.end())->revision.inner()().empty()); of << "format_version \"1\"\n\n" - "new_manifest []\n\n" + "new_manifest [0000000000000000000000000000000000000001]\n\n" "old_revision [" << (--edges.end())->revision.inner()() << "]\n"; } // like in commit ? ============================================================ --- mtn_cvs/testsuite.lua 8339314159b3c522337e0d3b6c0fb60e5ba36d70 +++ mtn_cvs/testsuite.lua fba339f4b18d305e89fb9b1aa7e8e8c4902f5ee4 @@ -284,3 +284,4 @@ table.insert(tests, "takeover_modified") table.insert(tests, "push_simple") table.insert(tests, "push_loop") table.insert(tests, "takeover_modified") +table.insert(tests, "takeover_basic")