# # # patch "ChangeLog" # from [d4d233a12637b1ea62e7733445ebd5e1ae55fd24] # to [8803e8c325c01cbfc14a0f3cb9945318b63e1452] # # patch "cmd_ws_commit.cc" # from [302e10f1890d72dcaadff9f2bae22fdf70f9cb7f] # to [7dc23e7fa867951dbc82b5bd2da8a3560f2e4fc6] # # patch "tests/import/__driver__.lua" # from [ef5c31f1013a6d102e7a9a3d783537f5c4d414f2] # to [5d260317de7f59c7cf7e03c7d872af83ee2cb806] # ============================================================ --- ChangeLog d4d233a12637b1ea62e7733445ebd5e1ae55fd24 +++ ChangeLog 8803e8c325c01cbfc14a0f3cb9945318b63e1452 @@ -1,3 +1,11 @@ +2006-12-18 Richard Levitte + + * cmd_ws_commit.cc (CMD_NO_WORKSPACE(import)): Wrap the add, + drop and commit calls in a try block so the temporary + bookkeeping directory can be properly cleared even when + there's an exception. + * tests/import/__driver__.lua: Add a test + 2006-12-15 Nathaniel Smith * paths.cc: Add a few more normalization tests for things like ============================================================ --- cmd_ws_commit.cc 302e10f1890d72dcaadff9f2bae22fdf70f9cb7f +++ cmd_ws_commit.cc 7dc23e7fa867951dbc82b5bd2da8a3560f2e4fc6 @@ -1069,34 +1069,43 @@ CMD_NO_WORKSPACE(import, N_("tree"), N_( app.create_workspace(dir); - revision_t rev; - make_revision_for_workspace(ident, cset(), rev); - app.work.put_work_rev(rev); + try + { + revision_t rev; + make_revision_for_workspace(ident, cset(), rev); + app.work.put_work_rev(rev); - // prepare stuff for 'add' and so on. - app.found_workspace = true; // Yup, this is cheating! + // prepare stuff for 'add' and so on. + app.found_workspace = true; // Yup, this is cheating! - vector empty_args; - options save_opts; - // add --unknown - save_opts.no_ignore = app.opts.no_ignore; - save_opts.exclude_patterns = app.opts.exclude_patterns; - app.opts.no_ignore = false; - app.opts.exclude_patterns = std::vector(); - app.opts.unknown = true; - process(app, "add", empty_args); - app.opts.unknown = false; - app.opts.no_ignore = save_opts.no_ignore; - app.opts.exclude_patterns = save_opts.exclude_patterns; + vector empty_args; + options save_opts; + // add --unknown + save_opts.no_ignore = app.opts.no_ignore; + save_opts.exclude_patterns = app.opts.exclude_patterns; + app.opts.no_ignore = false; + app.opts.exclude_patterns = std::vector(); + app.opts.unknown = true; + process(app, "add", empty_args); + app.opts.unknown = false; + app.opts.no_ignore = save_opts.no_ignore; + app.opts.exclude_patterns = save_opts.exclude_patterns; - // drop --missing - app.opts.missing = true; - process(app, "drop", empty_args); - app.opts.missing = false; + // drop --missing + app.opts.missing = true; + process(app, "drop", empty_args); + app.opts.missing = false; - // commit - if (!app.opts.dryrun) - process(app, "commit", empty_args); + // commit + if (!app.opts.dryrun) + process(app, "commit", empty_args); + } + catch (...) + { + // clean up before rethrowing + delete_dir_recursive(bookkeeping_root); + throw; + } // clean up delete_dir_recursive(bookkeeping_root); ============================================================ --- tests/import/__driver__.lua ef5c31f1013a6d102e7a9a3d783537f5c4d414f2 +++ tests/import/__driver__.lua 5d260317de7f59c7cf7e03c7d872af83ee2cb806 @@ -125,3 +125,13 @@ check(not qgrep("committed revision ", " "--message", "Import eight, dry run so shouldn't commit", "--branch", "importbranch"), 0, false, true) check(not qgrep("committed revision ", "stderr")) + +------------------------------------------------------------------------------ +-- Ninth attempt, importing from one of the export checkouts. +-- 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 seven, trying to import a workspace", + "--branch", "importbranch", + "--key", "address@hidden"), 1, false, false) +check(not exists("importdir/_MTN"))