# # # patch "NEWS" # from [453441b1e2f755d65e324487693924705d71c0d9] # to [a7df42a746e665bfc3bca6dd22f37d44a6813c76] # # patch "cmd_ws_commit.cc" # from [80bed2c83bd1148c2b374258431be11e102331e4] # to [9c785ae0644c40de2af6b18e543f1cc559868a11] # # patch "tests/import/__driver__.lua" # from [41e1d2848c3b4dd356da9e9dfb308d7dc3de0003] # to [8d908627db91341b0da043e92dd2091bdeb64b4c] # ============================================================ --- NEWS 453441b1e2f755d65e324487693924705d71c0d9 +++ NEWS a7df42a746e665bfc3bca6dd22f37d44a6813c76 @@ -57,6 +57,12 @@ Xxx Xxx 99 99:99:99 UTC 2010 commands such as `clone`, `automate remote` and `automate remote_stdio`. + - The import command now keeps the created bookkeeping root if + --dry-run is not specified. This makes it possible to re-use + the import directory as workspace and is also more closely + to what our documentation states, when it says that import + is basically "setup with a twist". + New Features Bugs Fixed @@ -69,6 +75,10 @@ Xxx Xxx 99 99:99:99 UTC 2010 message and only aborts if it can't find it anywhere (fixes monotone bug #30215) + - The import command no longer warns about not being able + to write out _MTN/options on --dry-run + (fixes monotone bug #30225) + Other Sun Jun 13 22:13:53 UTC 2010 ============================================================ --- cmd_ws_commit.cc 80bed2c83bd1148c2b374258431be11e102331e4 +++ cmd_ws_commit.cc 9c785ae0644c40de2af6b18e543f1cc559868a11 @@ -1825,48 +1825,52 @@ CMD_NO_WORKSPACE(import, "import", "", C F("import directory '%s' doesn't exists") % dir, F("import directory '%s' is a file") % dir); + system_path _MTN_dir = dir / path_component("_MTN"); + + require_path_is_nonexistent + (_MTN_dir, F("bookkeeping directory already exists in '%s'") % dir); + + directory_cleanup_helper remove_on_fail(_MTN_dir); + workspace::create_workspace(app.opts, app.lua, dir); workspace work(app); - try - { - revision_t rev; - make_revision_for_workspace(ident, cset(), rev); - work.put_work_rev(rev); + revision_t rev; + make_revision_for_workspace(ident, cset(), rev); + work.put_work_rev(rev); - // prepare stuff for 'add' and so on. - args_vector empty_args; - options save_opts; - // add --unknown - save_opts.exclude_patterns = app.opts.exclude_patterns; - app.opts.exclude_patterns = args_vector(); - app.opts.unknown = true; - app.opts.recursive = true; - process(app, make_command_id("workspace add"), empty_args); - app.opts.recursive = false; - app.opts.unknown = false; - app.opts.exclude_patterns = save_opts.exclude_patterns; + // prepare stuff for 'add' and so on. + args_vector empty_args; + options save_opts; + // add --unknown + save_opts.exclude_patterns = app.opts.exclude_patterns; + app.opts.exclude_patterns = args_vector(); + app.opts.unknown = true; + app.opts.recursive = true; + process(app, make_command_id("workspace add"), empty_args); + app.opts.recursive = false; + app.opts.unknown = false; + app.opts.exclude_patterns = save_opts.exclude_patterns; - // drop --missing - save_opts.no_ignore = app.opts.no_ignore; - app.opts.missing = true; - process(app, make_command_id("workspace drop"), empty_args); - app.opts.missing = false; - app.opts.no_ignore = save_opts.no_ignore; + // drop --missing + save_opts.no_ignore = app.opts.no_ignore; + app.opts.missing = true; + process(app, make_command_id("workspace drop"), empty_args); + app.opts.missing = false; + app.opts.no_ignore = save_opts.no_ignore; - // commit - if (!app.opts.dryrun) - process(app, make_command_id("workspace commit"), empty_args); + // commit + if (!app.opts.dryrun) + { + process(app, make_command_id("workspace commit"), empty_args); + remove_on_fail.commit(); } - catch (...) + else { - // clean up before rethrowing - delete_dir_recursive(bookkeeping_root); - throw; + // since the _MTN directory gets removed, don't try to write out + // _MTN/options at the end + workspace::used = false; } - - // clean up - delete_dir_recursive(bookkeeping_root); } CMD_NO_WORKSPACE(migrate_workspace, "migrate_workspace", "", CMD_REF(tree), ============================================================ --- tests/import/__driver__.lua 41e1d2848c3b4dd356da9e9dfb308d7dc3de0003 +++ tests/import/__driver__.lua 8d908627db91341b0da043e92dd2091bdeb64b4c @@ -11,11 +11,15 @@ check(mtn("import", "importdir", "--message", "Import one, fresh start", "--branch", "importbranch"), 0, false, false) +check(exists("importdir/_MTN")) + check(mtn("checkout", "exportdir1", "--branch", "importbranch"), 0, false, false) check(samefile("importdir/importmefirst", "exportdir1/importmefirst")) +remove("importdir/_MTN") + ------------------------------------------------------------------------------ -- Second attempt, import something with a changed file. writefile("importdir/importmefirst", "version 1 of first test file\n") @@ -35,6 +39,8 @@ check(samefile("importdir/importmefirst" check(not exists("exportdir2/importmeignored")) check(samefile("importdir/importmefirst", "exportdir2/importmefirst")) +remove("importdir/_MTN") + ------------------------------------------------------------------------------ -- Third attempt, import something with an added file. writefile("importdir/importmesecond", "version 0 of second test file\n") @@ -52,6 +58,8 @@ check(samefile("importdir/importmesecond check(samefile("importdir/importmefirst", "exportdir3/importmefirst")) check(samefile("importdir/importmesecond", "exportdir3/importmesecond")) +remove("importdir/_MTN") + ------------------------------------------------------------------------------ -- Fourth attempt, import something with a changed and a dropped file. remove("importdir/importmefirst") @@ -67,6 +75,8 @@ check(samefile("importdir/importmesecond check(not exists("exportdir4/importmefirst")) check(samefile("importdir/importmesecond", "exportdir4/importmesecond")) +remove("importdir/_MTN") + ------------------------------------------------------------------------------ -- Fifth attempt, this time adding a third file and importing relative to -- an earlier revision @@ -85,6 +95,8 @@ check(samefile("importdir/importmethird" check(samefile("importdir/importmesecond", "exportdir5/importmesecond")) check(samefile("importdir/importmethird", "exportdir5/importmethird")) +remove("importdir/_MTN") + ------------------------------------------------------------------------------ -- Sixth attempt, dropping a file and. -- Trying again against the head of the branch. Since there's a fork, @@ -109,13 +121,16 @@ check(samefile("importdir/importmethird" check(not exists("exportdir6/importmesecond")) check(samefile("importdir/importmethird", "exportdir6/importmethird")) +remove("importdir/_MTN") + ------------------------------------------------------------------------------ -- Seventh attempt, importing from one of the export checkouts. -- This attempt is expected to FAIL, because import should refuse to --- import from a workspace. +-- import from a workspace, but it should keep the original's workspace intact check(mtn("import", "exportdir2", "--message", "Import seven, trying to import a workspace", "--branch", "importbranch"), 1, false, false) +check(exists("exportdir2/_MTN")) ------------------------------------------------------------------------------ -- Eight attempt, this time just doing a dry run. @@ -124,12 +139,12 @@ check(mtn("import", "importdir", "--dry-run", "--message", "Import eight, dry run so shouldn't commit", "--branch", "importbranch"), 0, false, true) +check(not exists("importdir/_MTN")) check(not qgrep("committed revision ", "stderr")) ------------------------------------------------------------------------------ --- Ninth attempt, importing from one of the export checkouts. +-- Ninth attempt, fail and remove the temporary _MTN -- This attempt is expected to FAIL, because we gave it a non-existing key. --- However, we want to check that such an error didn't leave a _MTN behind. check(mtn("import", "importdir", "--message", "Import nine, trying to import a workspace", "--branch", "importbranch", @@ -150,6 +165,8 @@ check(exists("exportdir10/subdir10/impor check(exists("exportdir10/subdir10/importmesubdir")) +remove("importdir/_MTN") + ------------------------------------------------------------------------------ -- Eleventh attempt, checking that ignorable files aren't normally imported mkdir("importdir/subdir11") @@ -166,6 +183,8 @@ check(not exists("exportdir11/subdir11/f check(not exists("exportdir11/fake_test_hooks.lua")) check(not exists("exportdir11/subdir11/fake_test_hooks.lua")) +remove("importdir/_MTN") + ------------------------------------------------------------------------------ -- twelth attempt, now trying again, without ignoring. mkdir("importdir/subdir12")