# # # rename "tests/workspace_migration/test-1" # to "tests/workspace_migration/basic-1" # # rename "tests/workspace_migration/test-2" # to "tests/workspace_migration/basic-2" # # add_dir "tests/workspace_migration/inodeprints-1" # # add_dir "tests/workspace_migration/inodeprints-1/_MTN" # # add_dir "tests/workspace_migration/inodeprints-1/newdir" # # add_dir "tests/workspace_migration/inodeprints-2" # # add_dir "tests/workspace_migration/inodeprints-2/_MTN" # # add_dir "tests/workspace_migration/inodeprints-2/newdir" # # add_file "tests/workspace_migration/basic.lua" # content [49dbed3e6b96fb6c0ded16315b5b8aca148595e6] # # add_file "tests/workspace_migration/inodeprints-1/_MTN/inodeprints" # content [da39a3ee5e6b4b0d3255bfef95601890afd80709] # # add_file "tests/workspace_migration/inodeprints-1/_MTN/log" # content [d3664ada696aa1b7855394a2f7eee66281825adf] # # add_file "tests/workspace_migration/inodeprints-1/_MTN/monotonerc" # content [339d19b34553f03bce2ca334618ac0054a1fdd4e] # # add_file "tests/workspace_migration/inodeprints-1/_MTN/options" # content [a2a92cf608d8e19dee7ad9ac2c4c1d38e5d6bc76] # # add_file "tests/workspace_migration/inodeprints-1/_MTN/revision" # content [0b6f95ff1aa3b4d67e10d765254a26d5a37ebef8] # # add_file "tests/workspace_migration/inodeprints-1/_MTN/work" # content [345f6f7bfcc8d889dd158fe912517abae5488389] # # add_file "tests/workspace_migration/inodeprints-1/newdir/file3" # content [6cae7599afc389125f786f1d703ef2a9eea08424] # # add_file "tests/workspace_migration/inodeprints-1/renamed-testfile2" # content [535a99a5f65fad210c15c0b969d3aebe33cf405d] # # add_file "tests/workspace_migration/inodeprints-1/testfile1" # content [c01c44cca550f1b77ef5cda76c242e9c03d43cc8] # # add_file "tests/workspace_migration/inodeprints-2/_MTN/format" # content [7448d8798a4380162d4b56f9b452e2f6f9e24e7a] # # add_file "tests/workspace_migration/inodeprints-2/_MTN/inodeprints" # content [da39a3ee5e6b4b0d3255bfef95601890afd80709] # # add_file "tests/workspace_migration/inodeprints-2/_MTN/log" # content [d3664ada696aa1b7855394a2f7eee66281825adf] # # add_file "tests/workspace_migration/inodeprints-2/_MTN/monotonerc" # content [339d19b34553f03bce2ca334618ac0054a1fdd4e] # # add_file "tests/workspace_migration/inodeprints-2/_MTN/options" # content [a2a92cf608d8e19dee7ad9ac2c4c1d38e5d6bc76] # # add_file "tests/workspace_migration/inodeprints-2/_MTN/revision" # content [d37d8e18c4d00c0b17235f81c5021032e163df75] # # add_file "tests/workspace_migration/inodeprints-2/newdir/file3" # content [6cae7599afc389125f786f1d703ef2a9eea08424] # # add_file "tests/workspace_migration/inodeprints-2/renamed-testfile2" # content [535a99a5f65fad210c15c0b969d3aebe33cf405d] # # add_file "tests/workspace_migration/inodeprints-2/testfile1" # content [c01c44cca550f1b77ef5cda76c242e9c03d43cc8] # # add_file "tests/workspace_migration/inodeprints.lua" # content [1e810ab1fa2ffff1e74c05ca4fce226a5098e80b] # # patch "ChangeLog" # from [f56bc8da0290bce97607b0b319b87ea2e3a53976] # to [f9e96bcb4c8ab542d86cf9759887c94cefadbc09] # # patch "tests/workspace_migration/__driver__.lua" # from [76c2af7a10741587b02804a619be6727e6f26228] # to [7bbb0ae37bd598e625f2df0f6e5c11c46364855c] # ============================================================ --- tests/workspace_migration/basic.lua 49dbed3e6b96fb6c0ded16315b5b8aca148595e6 +++ tests/workspace_migration/basic.lua 49dbed3e6b96fb6c0ded16315b5b8aca148595e6 @@ -0,0 +1,33 @@ +---- If you change this code, you will have to regenerate all of the +---- "basic-N" workspaces. + +return { + min_format = 1, + creator = + function () + check(mtn("setup", "-b", "basicbranch", "basic-current")) + chdir("basic-current") + addfile("testfile1", "blah blah\n") + addfile("testfile2", "asdfas dfsa\n") + check(mtn("attr", "set", "testfile1", "test:attr", "fooooo"), + 0, false, false) + + commit("basicbranch") + + -- make some edits to the files + writefile("testfile1", "new stuff\n") + writefile("testfile2", "more new stuff\n") + -- and some tree rearrangement stuff too + check(mtn("rename", "--execute", "testfile2", "renamed-testfile2"), + 0, false, false) + check(mtn("attr", "set", "renamed-testfile2", "test:attr2", "asdf"), + 0, false, false) + check(mtn("attr", "drop", "testfile1", "test:attr"), + 0, false, false) + mkdir("newdir") + writefile("newdir/file3", "twas mimsy and the borogroves\n") + check(mtn("add", "newdir", "newdir/file3"), 0, false, false) + chdir("..") + end, + checker = function (dir, refdir) end +} ============================================================ --- tests/workspace_migration/inodeprints-1/_MTN/inodeprints da39a3ee5e6b4b0d3255bfef95601890afd80709 +++ tests/workspace_migration/inodeprints-1/_MTN/inodeprints da39a3ee5e6b4b0d3255bfef95601890afd80709 ============================================================ --- tests/workspace_migration/inodeprints-1/_MTN/log d3664ada696aa1b7855394a2f7eee66281825adf +++ tests/workspace_migration/inodeprints-1/_MTN/log d3664ada696aa1b7855394a2f7eee66281825adf @@ -0,0 +1 @@ +oh frabjous patch, calloo callay ============================================================ --- tests/workspace_migration/inodeprints-1/_MTN/monotonerc 339d19b34553f03bce2ca334618ac0054a1fdd4e +++ tests/workspace_migration/inodeprints-1/_MTN/monotonerc 339d19b34553f03bce2ca334618ac0054a1fdd4e @@ -0,0 +1 @@ +-- io.stderr:write("warning: bandersnatch insufficiently frumious\n") ============================================================ --- tests/workspace_migration/inodeprints-1/_MTN/options a2a92cf608d8e19dee7ad9ac2c4c1d38e5d6bc76 +++ tests/workspace_migration/inodeprints-1/_MTN/options a2a92cf608d8e19dee7ad9ac2c4c1d38e5d6bc76 @@ -0,0 +1,4 @@ +database "/twas/brillig/and/the/slithy/toves.mtn" + branch "did.gyre.and.gimble.in.the.wabe" + key "address@hidden" + keydir "/and/the/mome/raths/outgrabe" ============================================================ --- tests/workspace_migration/inodeprints-1/_MTN/revision 0b6f95ff1aa3b4d67e10d765254a26d5a37ebef8 +++ tests/workspace_migration/inodeprints-1/_MTN/revision 0b6f95ff1aa3b4d67e10d765254a26d5a37ebef8 @@ -0,0 +1 @@ +c2cdede98d20694daf470055a100bf74fdd8e615 ============================================================ --- tests/workspace_migration/inodeprints-1/_MTN/work 345f6f7bfcc8d889dd158fe912517abae5488389 +++ tests/workspace_migration/inodeprints-1/_MTN/work 345f6f7bfcc8d889dd158fe912517abae5488389 @@ -0,0 +1,14 @@ +rename "testfile2" + to "renamed-testfile2" + +add_dir "newdir" + +add_file "newdir/file3" + content [6cae7599afc389125f786f1d703ef2a9eea08424] + +clear "testfile1" + attr "test:attr" + + set "renamed-testfile2" + attr "test:attr2" +value "asdf" ============================================================ --- tests/workspace_migration/inodeprints-1/newdir/file3 6cae7599afc389125f786f1d703ef2a9eea08424 +++ tests/workspace_migration/inodeprints-1/newdir/file3 6cae7599afc389125f786f1d703ef2a9eea08424 @@ -0,0 +1 @@ +twas mimsy and the borogroves ============================================================ --- tests/workspace_migration/inodeprints-1/renamed-testfile2 535a99a5f65fad210c15c0b969d3aebe33cf405d +++ tests/workspace_migration/inodeprints-1/renamed-testfile2 535a99a5f65fad210c15c0b969d3aebe33cf405d @@ -0,0 +1 @@ +more new stuff ============================================================ --- tests/workspace_migration/inodeprints-1/testfile1 c01c44cca550f1b77ef5cda76c242e9c03d43cc8 +++ tests/workspace_migration/inodeprints-1/testfile1 c01c44cca550f1b77ef5cda76c242e9c03d43cc8 @@ -0,0 +1 @@ +new stuff ============================================================ --- tests/workspace_migration/inodeprints-2/_MTN/format 7448d8798a4380162d4b56f9b452e2f6f9e24e7a +++ tests/workspace_migration/inodeprints-2/_MTN/format 7448d8798a4380162d4b56f9b452e2f6f9e24e7a @@ -0,0 +1 @@ +2 ============================================================ --- tests/workspace_migration/inodeprints-2/_MTN/inodeprints da39a3ee5e6b4b0d3255bfef95601890afd80709 +++ tests/workspace_migration/inodeprints-2/_MTN/inodeprints da39a3ee5e6b4b0d3255bfef95601890afd80709 ============================================================ --- tests/workspace_migration/inodeprints-2/_MTN/log d3664ada696aa1b7855394a2f7eee66281825adf +++ tests/workspace_migration/inodeprints-2/_MTN/log d3664ada696aa1b7855394a2f7eee66281825adf @@ -0,0 +1 @@ +oh frabjous patch, calloo callay ============================================================ --- tests/workspace_migration/inodeprints-2/_MTN/monotonerc 339d19b34553f03bce2ca334618ac0054a1fdd4e +++ tests/workspace_migration/inodeprints-2/_MTN/monotonerc 339d19b34553f03bce2ca334618ac0054a1fdd4e @@ -0,0 +1 @@ +-- io.stderr:write("warning: bandersnatch insufficiently frumious\n") ============================================================ --- tests/workspace_migration/inodeprints-2/_MTN/options a2a92cf608d8e19dee7ad9ac2c4c1d38e5d6bc76 +++ tests/workspace_migration/inodeprints-2/_MTN/options a2a92cf608d8e19dee7ad9ac2c4c1d38e5d6bc76 @@ -0,0 +1,4 @@ +database "/twas/brillig/and/the/slithy/toves.mtn" + branch "did.gyre.and.gimble.in.the.wabe" + key "address@hidden" + keydir "/and/the/mome/raths/outgrabe" ============================================================ --- tests/workspace_migration/inodeprints-2/_MTN/revision d37d8e18c4d00c0b17235f81c5021032e163df75 +++ tests/workspace_migration/inodeprints-2/_MTN/revision d37d8e18c4d00c0b17235f81c5021032e163df75 @@ -0,0 +1,20 @@ +format_version "1" + +new_manifest [9296adf6738af28160271dc44c77c4e3927e17b6] + +old_revision [c2cdede98d20694daf470055a100bf74fdd8e615] + +rename "testfile2" + to "renamed-testfile2" + +add_dir "newdir" + +add_file "newdir/file3" + content [6cae7599afc389125f786f1d703ef2a9eea08424] + +clear "testfile1" + attr "test:attr" + + set "renamed-testfile2" + attr "test:attr2" +value "asdf" ============================================================ --- tests/workspace_migration/inodeprints-2/newdir/file3 6cae7599afc389125f786f1d703ef2a9eea08424 +++ tests/workspace_migration/inodeprints-2/newdir/file3 6cae7599afc389125f786f1d703ef2a9eea08424 @@ -0,0 +1 @@ +twas mimsy and the borogroves ============================================================ --- tests/workspace_migration/inodeprints-2/renamed-testfile2 535a99a5f65fad210c15c0b969d3aebe33cf405d +++ tests/workspace_migration/inodeprints-2/renamed-testfile2 535a99a5f65fad210c15c0b969d3aebe33cf405d @@ -0,0 +1 @@ +more new stuff ============================================================ --- tests/workspace_migration/inodeprints-2/testfile1 c01c44cca550f1b77ef5cda76c242e9c03d43cc8 +++ tests/workspace_migration/inodeprints-2/testfile1 c01c44cca550f1b77ef5cda76c242e9c03d43cc8 @@ -0,0 +1 @@ +new stuff ============================================================ --- tests/workspace_migration/inodeprints.lua 1e810ab1fa2ffff1e74c05ca4fce226a5098e80b +++ tests/workspace_migration/inodeprints.lua 1e810ab1fa2ffff1e74c05ca4fce226a5098e80b @@ -0,0 +1,41 @@ +---- If you change this code, you will have to regenerate all of the +---- "inodeprints-N" workspaces. + +return { + min_format = 1, + creator = + function () + check(mtn("setup", "-b", "inodeprints-branch", "inodeprints-current")) + chdir("inodeprints-current") + writefile("_MTN/inodeprints") + addfile("testfile1", "blah blah\n") + addfile("testfile2", "asdfas dfsa\n") + check(mtn("attr", "set", "testfile1", "test:attr", "fooooo"), + 0, false, false) + + commit("inodeprints-branch") + + -- make some edits to the files + writefile("testfile1", "new stuff\n") + writefile("testfile2", "more new stuff\n") + -- and some tree rearrangement stuff too + check(mtn("rename", "--execute", "testfile2", "renamed-testfile2"), + 0, false, false) + check(mtn("attr", "set", "renamed-testfile2", "test:attr2", "asdf"), + 0, false, false) + check(mtn("attr", "drop", "testfile1", "test:attr"), + 0, false, false) + mkdir("newdir") + writefile("newdir/file3", "twas mimsy and the borogroves\n") + check(mtn("add", "newdir", "newdir/file3"), 0, false, false) + check(mtn("refresh_inodeprints")) + chdir("..") + end, + checker = + function (dir, refdir) + -- We can't actually test that the inodeprints file came through + -- intact, because its content is unpredictable. Just make sure + -- it still exists. + check(exists(dir .. "/_MTN/inodeprints")) + end +} ============================================================ --- ChangeLog f56bc8da0290bce97607b0b319b87ea2e3a53976 +++ ChangeLog f9e96bcb4c8ab542d86cf9759887c94cefadbc09 @@ -1,5 +1,8 @@ 2007-02-09 Zack Weinberg + * tests/workspace_migration: Generalize to support different sorts + of migration-needing workspaces. + * cmd_list.cc (ls_known, ls_changed): Work in a two-parent workspace. * tests/two_parent_workspace_list: New test. * testsuite.lua: Add it. ============================================================ --- tests/workspace_migration/__driver__.lua 76c2af7a10741587b02804a619be6727e6f26228 +++ tests/workspace_migration/__driver__.lua 7bbb0ae37bd598e625f2df0f6e5c11c46364855c @@ -6,91 +6,68 @@ -- a new piece to this test, for the new format. The way you do this is to -- run this test with the -d option, like so: -- $ ./testsuite.lua -d workspace_migration --- this will cause the test to leave behind its temporary files. You want --- tester_dir/workspace_migration/current/ --- copy that directory to this directory, named test-, and --- update the 'current_workspace_format' variable at the top of this file. +-- this will cause the test to leave behind its temporary files. +-- Copy all the directories named +-- tester_dir/workspace_migration/-current/ +-- to this directory, rename them -, and update +-- the 'current_workspace_format' variable at the top of this file. -local current_workspace_format = 2 +-- If the workspace format change added possibilities to what the +-- workspace can represent, you may need to write a new workspace set, +-- which goes in its own little lua file. Pick a , name the +-- file .lua, and add to the workspace_sets array below. +-- The file should return a table with three entries. +-- +-- 'creator' is a function of no arguments that creates a live +-- workspace named '-current' which makes use of the new +-- feature. If it needs to make commits, it should do so only on +-- branches whose name begins with . +-- +-- 'min_format' is the minimum workspace format version that can +-- represent the workspace you construct in 'creator'. +-- +-- 'checker' is a function that takes two workspace directories as an +-- argument, verifies that the first one still has any interesting +-- properties given it by 'creator', and that (to the maximum extent +-- possible) those properties are consistent with the same properties +-- held by the second directory. +-- +-- It should not be necessary to modify the creator function after it +-- is written; the checker function may well need updating for future +-- workspace structures. Note that the code in this file does a +-- certain amount of common work setting up and checking the +-- workspaces; do not duplicate that work in creators or checkers. -mtn_setup() +local current_workspace_format = 2 --------------------------------------------------------------------------------------------------------------------------------------------- ----- Do not touch this code; you'll have to regenerate all the test ----- workspaces if you do! --------------------------------------------------------------------------------------------------------------------------------------------- +local workspace_sets = { + "basic", + "inodeprints", +} -addfile("testfile1", "blah blah\n") -addfile("testfile2", "asdfas dfsa\n") -check(mtn("attr", "set", "testfile1", "test:attr", "fooooo"), 0, false, false) -commit("testbranch") -base_rev = base_revision() - -check(mtn("checkout", "-r", base_rev, "current"), 0, false, false) --- make some edits to the files -writefile("current/testfile1", "new stuff\n") -writefile("current/testfile2", "more new stuff\n") --- and some tree rearrangement stuff too -check(indir("current", mtn("rename", "--execute", "testfile2", "renamed-testfile2")), - 0, false, false) -check(indir("current", mtn("attr", "set", "renamed-testfile2", "test:attr2", "asdf")), - 0, false, false) -check(indir("current", mtn("attr", "drop", "testfile1", "test:attr")), - 0, false, false) -mkdir("current/newdir") -writefile("current/newdir/file3", "twas mimsy and the borogroves\n") -check(indir("current", mtn("add", "newdir", "newdir/file3")), 0, false, false) - --- _MTN/log -writefile("current/_MTN/log", "oh frabjous patch, calloo callay\n") --- _MTN/monotonerc -writefile("current/_MTN/monotonerc", - '-- io.stderr:write("warning: bandersnatch insufficiently frumious\\n")\n') - --- _MTN/options - --- we set all the options, by hand, to complete nonsense, because --- (a) the migration operation is not supposed to need any information --- from this file, and (b) monotone should not clobber the options --- file, even if the corresponding command line options are given, when --- it doesn't understand the bookkeeping format. we save the nonsense --- separately from current/_MTN/options to ensure that that, too, isn't --- getting clobbered. - -writefile("nonsense-options", - 'database "/twas/brillig/and/the/slithy/toves.mtn"\n'.. - ' branch "did.gyre.and.gimble.in.the.wabe"\n'.. - ' key "address@hidden"\n'.. - ' keydir "/and/the/mome/raths/outgrabe"\n') -copy("nonsense-options", "current/_MTN/options") - --------------------------------------------------------------------------------------------------------------------------------------------- ----- End untouchable code --------------------------------------------------------------------------------------------------------------------------------------------- - -function check_workspace_matches_current(ws) - check(samefile("nonsense-options", ws.."/_MTN/options")) - check(indir("current", mtn("automate", "get_revision")), 0, true, false) +function check_workspace_matches_current(dir, refdir) + check(samefile("nonsense-options", dir.."/_MTN/options")) + check(indir(refdir, mtn("automate", "get_revision")), 0, true, false) rename("stdout", "current-rev") - check(indir(ws, mtn("automate", "get_revision")), 0, true, false) - rename("stdout", ws .. "-current-rev") - check(samefile("current-rev", ws.."-current-rev")) + check(indir(dir, mtn("automate", "get_revision")), 0, true, false) + check(samefile("stdout", "current-rev")) -- and the log file - check(samefile("current/_MTN/log", ws .. "/_MTN/log")) + check(samefile(dir .. "/_MTN/log", refdir .. "/_MTN/log")) -- we'd like to check that the hook file is being read, but we can't, -- because we can't tell monotone to read _MTN/monotonerc without also -- telling it to read ~/.monotone/monotonerc, and that would be bad in a -- test environment. So we content ourselves with just checking the file -- came through and is in the right place. - --check(indir(ws, mtn("status")), 0, true, false) + --check(indir(dir, mtn("status")), 0, true, false) --check(qgrep("bandersnatch", "stderr")) - check(samefile("current/_MTN/monotonerc", ws .. "/_MTN/monotonerc")) + check(samefile(dir .. "/_MTN/monotonerc", refdir .. "/_MTN/monotonerc")) end -function check_migrate_from(version) +function check_migrate_from(thing, version, checker) L(locheader(), - "checking migration from workspace format version ", version, "\n") - local ws = "test-" .. version + "checking migration of ", thing, "workspace from format version ", + version, "\n") + local ws = thing .. "-" .. version get(ws, ws) if (exists(ws .. "/_MTN/format")) then check(readfile(ws .. "/_MTN/format") == (version .. "\n")) @@ -107,10 +84,39 @@ function check_migrate_from(version) check(indir(ws, raw_mtn("migrate_workspace")), 0, false, false) -- now we should be the current version, and things should work check(readfile(ws .. "/_MTN/format") == (current_workspace_format .. "\n")) - check_workspace_matches_current(ws) + check_workspace_matches_current(ws, thing .. "-current") + checker(ws, thing .. "-current") check(indir(ws, mtn("status")), 0, false, false) end -for i = 1,current_workspace_format do - check_migrate_from(i) +mtn_setup() + +-- we set all the options, by hand, to complete nonsense, because +-- (a) the migration operation is not supposed to need any information +-- from this file, and (b) monotone should not clobber the options +-- file, even if the corresponding command line options are given, when +-- it doesn't understand the bookkeeping format. we save the nonsense +-- separately from current/_MTN/options to ensure that that, too, isn't +-- getting clobbered. + +writefile("nonsense-options", + 'database "/twas/brillig/and/the/slithy/toves.mtn"\n'.. + ' branch "did.gyre.and.gimble.in.the.wabe"\n'.. + ' key "address@hidden"\n'.. + ' keydir "/and/the/mome/raths/outgrabe"\n') + +for _, thing in pairs(workspace_sets) do + -- tester.lua is not very helpful here + local tbl = dofile(testdir .. "/" .. test.name .. "/" .. thing .. ".lua") + + tbl.creator() + writefile(thing.."-current/_MTN/log", "oh frabjous patch, calloo callay\n") + writefile(thing.."-current/_MTN/monotonerc", + '-- io.stderr:write("warning: bandersnatch '.. + 'insufficiently frumious\\n")\n') + copy("nonsense-options", thing.."-current/_MTN/options") + + for i = tbl.min_format, current_workspace_format do + check_migrate_from(thing, i, tbl.checker) + end end