# # # add_dir "tests/setup_creates_internal_db" # # add_file "tests/setup_creates_internal_db/__driver__.lua" # content [0fe19d0fe9c89e94709512594a3c45d3660b4992] # # patch "NEWS" # from [b4ae9a844b5b0f8f0f555c0f3fedf71dd3ae8d9a] # to [aa3540201e6eeaf00f80cef48001fdfff61d3644] # # patch "cmd_netsync.cc" # from [754f438fb04a0d11fc076b611aab56496d927a14] # to [d9f67662d472a86633a273dfd0116d735e14293c] # # patch "cmd_ws_commit.cc" # from [cdd35c77cdf518bca04ae40f191bc8ccc30ff33c] # to [1ba1ef2dbd72ffff9ea6c436d2b744a6dff49c7d] # # patch "paths.hh" # from [16f68fd413cd8c13bcb7756bdfbccfddb181215f] # to [08558986bab9f92e47d7cb678ef8cdf19f50be8c] # ============================================================ --- tests/setup_creates_internal_db/__driver__.lua 0fe19d0fe9c89e94709512594a3c45d3660b4992 +++ tests/setup_creates_internal_db/__driver__.lua 0fe19d0fe9c89e94709512594a3c45d3660b4992 @@ -0,0 +1,9 @@ + +check(getstd("test_keys")) +check(getstd("test_hooks.lua")) +check(getstd("min_hooks.lua")) + +check(nodb_mtn("setup", "--branch=testbranch", "."), 0, false, false) + +check(exists("_MTN/mtn.db")) +check(fsize("_MTN/mtn.db") > 0) ============================================================ --- NEWS b4ae9a844b5b0f8f0f555c0f3fedf71dd3ae8d9a +++ NEWS aa3540201e6eeaf00f80cef48001fdfff61d3644 @@ -4,6 +4,9 @@ xxx xxx xx xx:xx:xx UTC 2010 Changes + - The 'setup' command now creates a new internal database if no + database is given either as command line or workspace option. + New features - New automation command 'update' which behaves identical to ============================================================ --- cmd_netsync.cc 754f438fb04a0d11fc076b611aab56496d927a14 +++ cmd_netsync.cc d9f67662d472a86633a273dfd0116d735e14293c @@ -49,8 +49,6 @@ static const var_key default_exclude_pat static const var_key default_exclude_pattern_key(var_domain("database"), var_name("default-exclude-pattern")); -static char const ws_internal_db_file_name[] = "mtn.db"; - static void find_key(options & opts, database & db, @@ -742,7 +740,7 @@ CMD(clone, "clone", "", CMD_REF(network) if (internal_db) app.opts.dbname = system_path(workspace_dir / bookkeeping_root_component - / ws_internal_db_file_name); + / bookkeeping_internal_db_file_name); // this is actually stupid, but app.opts.branch must be set here // otherwise it will not be written into _MTN/options, in case ============================================================ --- cmd_ws_commit.cc cdd35c77cdf518bca04ae40f191bc8ccc30ff33c +++ cmd_ws_commit.cc 1ba1ef2dbd72ffff9ea6c436d2b744a6dff49c7d @@ -1377,21 +1377,37 @@ CMD_NO_WORKSPACE(setup, "setup", "", CMD { if (args.size() > 1) throw usage(execid); + E(!app.opts.branch().empty(), origin::user, F("need --branch argument for setup")); - database db(app); - db.ensure_open(); - string dir; if (args.size() == 1) dir = idx(args,0)(); else dir = "."; - workspace::create_workspace(app.opts, app.lua, system_path(dir, origin::user)); - workspace work(app); + system_path workspace_dir(dir, origin::user); + workspace::create_workspace(app.opts, app.lua, workspace_dir); + + if (app.opts.dbname_given || app.opts.dbname.empty()) + { + app.opts.dbname = system_path(workspace_dir + / bookkeeping_root_component + / bookkeeping_internal_db_file_name); + } + + database db(app); + if (get_path_status(db.get_filename()) == path::nonexistent) + { + P(F("initializing new database '%s'") % db.get_filename()); + db.initialize(); + } + + db.ensure_open(); + + workspace work(app); revision_t rev; make_revision_for_workspace(revision_id(), cset(), rev); work.put_work_rev(rev); ============================================================ --- paths.hh 16f68fd413cd8c13bcb7756bdfbccfddb181215f +++ paths.hh 08558986bab9f92e47d7cb678ef8cdf19f50be8c @@ -348,6 +348,7 @@ private: #define bookkeeping_root (bookkeeping_path("_MTN")) #define bookkeeping_root_component (path_component("_MTN")) +#define bookkeeping_internal_db_file_name (path_component("mtn.db")) // for migration #define old_bookkeeping_root_component (path_component("MT"))