# # # add_dir "tests/branch_leaves_sync_bug" # # add_file "tests/branch_leaves_sync_bug/__driver__.lua" # content [b07136d83463e208ef345d97415e53eafd244203] # ============================================================ --- tests/branch_leaves_sync_bug/__driver__.lua b07136d83463e208ef345d97415e53eafd244203 +++ tests/branch_leaves_sync_bug/__driver__.lua b07136d83463e208ef345d97415e53eafd244203 @@ -0,0 +1,80 @@ +-- In mtn 0.46 .. 0.47, branch_leaves table was corrupted by this scenario: +-- +-- Two developers working on the same branch do the same merge, one +-- adds another commit, then they sync +-- +-- The bug does not occur if the two workspaces use the same author +-- name and key. + +function abe_mtn(...) + return raw_mtn("--rcfile", test.root .. "/min_hooks.lua", + "--db=" .. test.root .. "/abe.db", + "--keydir", test.root .. "/keys", + "address@hidden", + ...) +end + +function beth_mtn(...) + return raw_mtn("--rcfile", test.root .. "/min_hooks.lua", + "--db=" .. test.root .. "/beth.db", + "--keydir", test.root .. "/keys", + "address@hidden", + ...) +end + +-- we don't use 'mtn_setup()', because we want two separate developers +check(getstd("min_hooks.lua")) +mkdir("Abe") +check(abe_mtn("db", "init"), 0, false, false) +copy("abe.db", "beth.db") + +chdir("Abe") +check(abe_mtn("genkey", "address@hidden"), 0, false, false, string.rep("address@hidden", 2)) +check(abe_mtn("setup", "--branch", "testbranch"), 0, false, false) + +addfile("file1", "base", abe_mtn) +commit("testbranch", "base", abe_mtn) +base = base_revision() + +-- Create Beth's workspace via checkout, so 'update' works +chdir(test.root) +check(abe_mtn("sync", "file://" .. test.root .. "/beth.db", "*"), 0, false, false) +check(beth_mtn("checkout", "--branch", "testbranch", "Beth"), 0, false, false) +chdir("Beth") +check(beth_mtn("genkey", "address@hidden"), 0, false, false, string.rep("address@hidden", 2)) + +-- Abe creates two heads on testbranch +chdir("../Abe") +writefile("file1", "rev_a") +commit("testbranch", "rev_a", abe_mtn) +rev_a = base_revision() + +revert_to(base, "testbranch", abe_mtn) + +addfile("file2", "rev_b", abe_mtn) +commit("testbranch", "rev_b", abe_mtn) +rev_b = base_revision() + +-- Sync dbs +check(abe_mtn("sync", "file://" .. test.root .. "/beth.db", "*"), 0, false, false) + +-- Abe merges +chdir("Abe") +check(abe_mtn("merge", "--message", "rev_c"), 0, false, false) + +-- Beth merges, and adds another revision +chdir("../Beth") +check(beth_mtn("merge", "--message", "rev_c"), 0, false, false) +check(beth_mtn("update"), 0, false, false) + +writefile("file2", "rev_d", beth_mtn) +commit("testbranch", "rev_d", beth_mtn) +rev_d = base_revision() + +-- Sync dbs (not clear if direction of sync matters) +check(beth_mtn("sync", "file://" .. test.root .. "/abe.db", "*"), 0, false, false) + +-- bug; rev_d and rev_c are both heads according to branch_leaves table. +check(beth_mtn("db", "check"), 0, false, false) + +-- end of file