# # # patch "cmd_db.cc" # from [d70d3eb0c456fc31de08cd9f16c487fc02d2e3fe] # to [115c73023e0a189024919d709d3947196dd69083] # # patch "database.cc" # from [1cd8904da0236db3a8c5b7d49ed29e3d651ba3df] # to [e307170688d9a799c173e9111639a59481539de5] # # patch "database.hh" # from [e3de5162c6654e1355444eb0d6c4d8bd6c0fe63b] # to [c462132eab925d3c0ce2d1d2c0d5dfe3c8479c6b] # # patch "migrate_schema.cc" # from [ffd51091a60a67132b1fd88514fd50d04f0e17f8] # to [a5fb01151cd2fa3a4c422ebb3f2258d9c935f328] # # patch "migration.hh" # from [a69a8f22bc9fad780e35cd11c2594425de198f49] # to [eddb224da22ddb812472fde688ca4ae8ce21bbeb] # # patch "tests/_MTN_case-folding_security_patch/__driver__.lua" # from [2ed48a126f4f597050edc0ae0d3dea6ab264327b] # to [ea44e3f48bf63cd83d08e7db00aaca59b2f6a779] # # patch "tests/schema_migration/__driver__.lua" # from [e620abf0939cdc33e621d4d5c31b9c462aaee663] # to [96bc894d98dc867567f5d30923e0781f145cf3fd] # # patch "tests/schema_migration_with_rosterify/__driver__.lua" # from [80ac89fc45999c5cf8285062b2fca14ce9c962b8] # to [4f4a73dc101a3096ea2c5b5e0ad1493e15d93c9c] # # patch "tests/unnormalized_paths_in_database/__driver__.lua" # from [cdf29f521361c390732d47de1b64b45c167c8775] # to [1e65533735beba77f5a8d444004c2ae37895a000] # ============================================================ --- cmd_db.cc d70d3eb0c456fc31de08cd9f16c487fc02d2e3fe +++ cmd_db.cc 115c73023e0a189024919d709d3947196dd69083 @@ -116,8 +116,26 @@ CMD(db_migrate, "migrate", "", CMD_REF(d E(args.size() == 0, origin::user, F("no arguments needed")); - database db(app); - db.migrate(keys); + migration_status mstat; + { + database db(app); + db.migrate(keys, mstat); + app.dbcache.reset(); + } + + if (mstat.need_regen()) + { + database db(app); + regenerate_caches(db); + } + + if (mstat.need_flag_day()) + { + P(F("NOTE: because this database was last used by a rather old version\n" + "of monotone, you're not done yet. If you're a project leader, then\n" + "see the file UPGRADE for instructions on running '%s db %s'") + % prog_name % mstat.flag_day_name()); + } } CMD(db_execute, "execute", "", CMD_REF(db), "", ============================================================ --- database.cc 1cd8904da0236db3a8c5b7d49ed29e3d651ba3df +++ database.cc e307170688d9a799c173e9111639a59481539de5 @@ -1184,10 +1184,10 @@ void } void -database::migrate(key_store & keys) +database::migrate(key_store & keys, migration_status & mstat) { ensure_open_for_maintenance(); - migrate_sql_schema(imp->__sql, keys, get_filename()); + mstat = migrate_sql_schema(imp->__sql, keys, get_filename()); } void ============================================================ --- database.hh e3de5162c6654e1355444eb0d6c4d8bd6c0fe63b +++ database.hh c462132eab925d3c0ce2d1d2c0d5dfe3c8479c6b @@ -28,6 +28,8 @@ class lazy_rng; class rev_height; class lazy_rng; +class migration_status; + typedef std::pair var_key; typedef enum {cert_ok, cert_bad, cert_unknown} cert_status; @@ -388,7 +390,7 @@ public: void load(std::istream &); void info(std::ostream &, bool analyze); void version(std::ostream &); - void migrate(key_store &); + void migrate(key_store &, migration_status &); void test_migration_step(key_store &, std::string const &); // for kill_rev_locally: void delete_existing_rev_and_certs(revision_id const & rid); ============================================================ --- migrate_schema.cc ffd51091a60a67132b1fd88514fd50d04f0e17f8 +++ migrate_schema.cc a5fb01151cd2fa3a4c422ebb3f2258d9c935f328 @@ -1008,7 +1008,7 @@ void sqlite3_hex_fn(sqlite3_context *f, void sqlite3_hex_fn(sqlite3_context *f, int nargs, sqlite3_value **args); #endif -void +migration_status migrate_sql_schema(sqlite3 * db, key_store & keys, system_path const & filename) { @@ -1041,7 +1041,7 @@ migrate_sql_schema(sqlite3 * db, key_sto if (cat == SCHEMA_MATCHES) { P(F("no migration performed; database schema already up-to-date")); - return; + return migration_status(false); } #ifdef SUPPORT_SQLITE_BEFORE_3003014 @@ -1093,20 +1093,16 @@ migrate_sql_schema(sqlite3 * db, key_sto { string command_str = (regime == upgrade_changesetify ? "changesetify" : "rosterify"); - P(F("NOTE: because this database was last used by a rather old version\n" - "of monotone, you're not done yet. If you're a project leader, then\n" - "see the file UPGRADE for instructions on running '%s db %s'") - % prog_name % command_str); + return migration_status(false, command_str); } break; case upgrade_regen_caches: - P(F("NOTE: this upgrade cleared monotone's caches\n" - "you should now run '%s db regenerate_caches'") - % prog_name); + return migration_status(true); break; case upgrade_none: break; } + return migration_status(false); } // test_migration_step runs the migration step from SCHEMA to its successor, ============================================================ --- migration.hh a69a8f22bc9fad780e35cd11c2594425de198f49 +++ migration.hh eddb224da22ddb812472fde688ca4ae8ce21bbeb @@ -26,9 +26,23 @@ void check_sql_schema(sqlite3 * db, syst std::string describe_sql_schema(sqlite3 * db); void check_sql_schema(sqlite3 * db, system_path const & filename); -void migrate_sql_schema(sqlite3 * db, key_store & keys, - system_path const & filename); +class migration_status { + bool _need_regen; + std::string _flag_day_name; +public: + migration_status(){} + explicit migration_status(bool regen, std::string flag_day_name = "") + : _need_regen(regen), + _flag_day_name(flag_day_name) + {} + bool need_regen() const { return _need_regen; } + bool need_flag_day() const { return !_flag_day_name.empty(); } + std::string flag_day_name() const { return _flag_day_name; } +}; +migration_status migrate_sql_schema(sqlite3 * db, key_store & keys, + system_path const & filename); + // utility routine shared with database.cc void assert_sqlite3_ok(sqlite3 * db); ============================================================ --- tests/_MTN_case-folding_security_patch/__driver__.lua 2ed48a126f4f597050edc0ae0d3dea6ab264327b +++ tests/_MTN_case-folding_security_patch/__driver__.lua ea44e3f48bf63cd83d08e7db00aaca59b2f6a779 @@ -61,6 +61,6 @@ for _,i in pairs({"files", "dirs"}) do for _,i in pairs({"files", "dirs"}) do get(i..".db.dumped", "stdin") check(mtn("db", "load", "-d", i..".mtn"), 0, false, false, true) - check(mtn("db", "migrate", "-d", i..".mtn"), 0, false, false) - check(mtn("-d", i..".mtn", "db", "regenerate_caches"), 3, false, false) + check(mtn("db", "migrate", "-d", i..".mtn"), 3, false, false) + --check(mtn("-d", i..".mtn", "db", "regenerate_caches"), 3, false, false) end ============================================================ --- tests/schema_migration/__driver__.lua e620abf0939cdc33e621d4d5c31b9c462aaee663 +++ tests/schema_migration/__driver__.lua 96bc894d98dc867567f5d30923e0781f145cf3fd @@ -81,7 +81,7 @@ end ---- End untouchable code ---------------------------------------------------------------------------- -function check_migrate_from(id, need_regen_rosters) +function check_migrate_from(id) -- id.dumped is a 'db dump' of a db with schema "id" get(id..".mtn.dumped", "stdin") check(mtn("--db="..id..".mtn", "db", "load"), 0, false, false, true) @@ -90,32 +90,18 @@ function check_migrate_from(id, need_reg check(qgrep(id, "stdout")) -- migrate it check(mtn("--db="..id..".mtn", "db", "migrate"), 0, false, true) - -- check to see if it told us to regenerate_caches - if (need_regen_rosters) then - -- then the migrate should have warned us - check(string.find(readfile("stderr"), "regenerate_caches") ~= nil) - -- and normal commands on the db should notice the problem and error out - check(mtn("--db="..id..".mtn", "ls", "keys"), 1, false, true) - check(qgrep("regenerate_caches", "stderr")) - -- and we should do the regeneration - check(mtn("--db="..id..".mtn", "db", "regenerate_caches"), 0, false, false) - -- after which, normal commands should work again - check(mtn("--db="..id..".mtn", "ls", "keys"), 0, false, true) - check(not qgrep("regenerate_caches", "stderr")) - else - -- then the migrate should not have warned us - check(string.find(readfile("stderr"), "regenerate_caches") == nil) - -- and normal commands on the db should work fine - check(mtn("--db="..id..".mtn", "ls", "keys"), 0, false, true) - check(not qgrep("regenerate_caches", "stderr")) - end + -- then the migrate should not have warned us + check(string.find(readfile("stderr"), "regenerate_caches") == nil) + -- and normal commands on the db should work fine + check(mtn("--db="..id..".mtn", "ls", "keys"), 0, false, true) + check(not qgrep("regenerate_caches", "stderr")) check_same_db_contents(id..".mtn", "latest.mtn") end -check_migrate_from("1db80c7cee8fa966913db1a463ed50bf1b0e5b0e", true) -check_migrate_from("9d2b5d7b86df00c30ac34fe87a3c20f1195bb2df", true) -check_migrate_from("ae196843d368d042f475e3dadfed11e9d7f9f01e", true) -check_migrate_from("48fd5d84f1e5a949ca093e87e5ac558da6e5956d", false) -check_migrate_from("fe48b0804e0048b87b4cea51b3ab338ba187bdc2", false) -check_migrate_from("7ca81b45279403419581d7fde31ed888a80bd34e", false) -check_migrate_from("212dd25a23bfd7bfe030ab910e9d62aa66aa2955", false) +check_migrate_from("1db80c7cee8fa966913db1a463ed50bf1b0e5b0e") +check_migrate_from("9d2b5d7b86df00c30ac34fe87a3c20f1195bb2df") +check_migrate_from("ae196843d368d042f475e3dadfed11e9d7f9f01e") +check_migrate_from("48fd5d84f1e5a949ca093e87e5ac558da6e5956d") +check_migrate_from("fe48b0804e0048b87b4cea51b3ab338ba187bdc2") +check_migrate_from("7ca81b45279403419581d7fde31ed888a80bd34e") +check_migrate_from("212dd25a23bfd7bfe030ab910e9d62aa66aa2955") ============================================================ --- tests/schema_migration_with_rosterify/__driver__.lua 80ac89fc45999c5cf8285062b2fca14ce9c962b8 +++ tests/schema_migration_with_rosterify/__driver__.lua 4f4a73dc101a3096ea2c5b5e0ad1493e15d93c9c @@ -83,7 +83,9 @@ function check_migrate_from(id) check(qgrep(id, "stdout")) -- migrate it check(mtn("--db="..id..".mtn", "db", "migrate"), 0, false, false) + check(mtn("--db="..id..".mtn", "ls", "branches"), 1, false, false) check(mtn("--db="..id..".mtn", "db", "rosterify"), 0, false, false) + check(mtn("--db="..id..".mtn", "ls", "branches"), 0, false, false) check_same_db_contents(id..".mtn", "latest.mtn") end ============================================================ --- tests/unnormalized_paths_in_database/__driver__.lua cdf29f521361c390732d47de1b64b45c167c8775 +++ tests/unnormalized_paths_in_database/__driver__.lua 1e65533735beba77f5a8d444004c2ae37895a000 @@ -16,6 +16,6 @@ check(get("bad.db")) check(get("bad.db")) -check(mtn("db", "migrate", "-d", "bad.db"), 0, false, false) +check(mtn("db", "migrate", "-d", "bad.db"), 3, false, false) -check(mtn("db", "regenerate_caches", "-d", "bad.db"), 3, false, true) +--check(mtn("db", "regenerate_caches", "-d", "bad.db"), 3, false, true)