# # # add_dir "tests/setup_and_clone_keep_bookkeeping_dir" # # add_file "tests/setup_and_clone_keep_bookkeeping_dir/__driver__.lua" # content [1edbe6e32a556b30d856ffe60801a80208942803] # # patch "NEWS" # from [575d523cbf9917f69c1619a87bb326bbc50361df] # to [357a526c862a2a76e845af50d5f2fbc3fa40c339] # # patch "cmd_netsync.cc" # from [1ac88de69ed8fc8c418e52f4cdcfa0746a892c8a] # to [f7d2a20bcedc5ea1c62953f560b82ce79b9e795d] # # patch "cmd_ws_commit.cc" # from [de0a31f5fabd53d2291b3bedd679d571cb188646] # to [3ffbaa10b5e4c72028f08fcbf06950e5997b7c69] # ============================================================ --- tests/setup_and_clone_keep_bookkeeping_dir/__driver__.lua 1edbe6e32a556b30d856ffe60801a80208942803 +++ tests/setup_and_clone_keep_bookkeeping_dir/__driver__.lua 1edbe6e32a556b30d856ffe60801a80208942803 @@ -0,0 +1,18 @@ +-- +-- This is a test for bug #29927 - before monotone 0.47 if clone +-- was executed in a directory with an existing bookkeeping directory +-- then this directory was removed on failure, actively destroying an +-- existing workspace +-- + + +mtn_setup() +check(exists("_MTN")) + +check(mtn("setup", "-b", "test.branch", "."), 1, false, true) +check(qgrep("bookkeeping directory already exists", "stderr")) +check(exists("_MTN")) + +check(mtn("clone", "somewhere", "test.branch", "."), 1, false, true) +check(qgrep("bookkeeping directory already exists", "stderr")) +check(exists("_MTN")) ============================================================ --- NEWS 575d523cbf9917f69c1619a87bb326bbc50361df +++ NEWS 357a526c862a2a76e845af50d5f2fbc3fa40c339 @@ -96,6 +96,10 @@ xxx xxx xx xx:xx:xx UTC 2010 whose parent revision(s) do not exist in the specified database (fixes monotone bug #29677). + - The 'clone' command no longer removes an existing bookkeeping + directory if the target directory "." points to a workspace + (fixes monotone bug #29927). + - monotone on Windows will now have a non-zero exit code when interrupted (^C). This was broken in 0.47 when it was fixed to not throw an exception on being interrupted. ============================================================ --- cmd_netsync.cc 1ac88de69ed8fc8c418e52f4cdcfa0746a892c8a +++ cmd_netsync.cc f7d2a20bcedc5ea1c62953f560b82ce79b9e795d @@ -692,15 +692,20 @@ CMD(clone, "clone", "", CMD_REF(network) % workspace_dir); } - // remember the initial working dir so that relative file:// - // db URIs will work - system_path start_dir(get_current_working_dir(), origin::system); + system_path _MTN_dir = workspace_dir / path_component("_MTN"); - system_path _MTN_dir = workspace_dir / path_component("_MTN"); + require_path_is_nonexistent + (_MTN_dir, F("bookkeeping directory already exists in '%s'") + % workspace_dir); + directory_cleanup_helper remove_on_fail( target_is_current_dir ? _MTN_dir : workspace_dir ); + // remember the initial working dir so that relative file:// + // db URIs will work + system_path start_dir(get_current_working_dir(), origin::system); + // paths.cc's idea of the current workspace root is wrong at this point if (!app.opts.dbname_given || app.opts.dbname.empty()) app.opts.dbname = system_path(workspace_dir ============================================================ --- cmd_ws_commit.cc de0a31f5fabd53d2291b3bedd679d571cb188646 +++ cmd_ws_commit.cc 3ffbaa10b5e4c72028f08fcbf06950e5997b7c69 @@ -1693,13 +1693,16 @@ CMD_NO_WORKSPACE(setup, "setup", "", CMD dir = "."; system_path workspace_dir(dir, origin::user); + system_path _MTN_dir(workspace_dir / bookkeeping_root_component); + require_path_is_nonexistent + (_MTN_dir, F("bookkeeping directory already exists in '%s'") + % workspace_dir); + // only try to remove the complete workspace directory // if we're about to create it anyways directory_cleanup_helper remove_on_fail( - directory_exists(workspace_dir) - ? workspace_dir / bookkeeping_root_component - : workspace_dir + directory_exists(workspace_dir) ? _MTN_dir : workspace_dir ); workspace::create_workspace(app.opts, app.lua, workspace_dir);