# # patch "ChangeLog" # from [b4d51f001fa9a08f9bf5fe6730d4b7022a25fde7] # to [7b844b50a9d3fa85fdf58f4bd805c9906312d1c1] # # patch "contrib/ciabot_monotone.py" # from [53817a19420055452a332b922bd85e414b2b042f] # to [7c3c9404806ed0572e888ad12a206c7438884ec1] # # patch "schema_migration.cc" # from [06a7e2c801bb9d6e789f3883fa781a394993250a] # to [321533da055eb96c09cfb11ae0215aa0c7e41e3a] # --- ChangeLog +++ ChangeLog @@ -11,6 +11,17 @@ 2005-07-13 Nathaniel Smith + * contrib/ciabot_monotone.py (main): Optimistically run 'db + migrate' before using database. + +2005-07-13 Nathaniel Smith + + * schema_migration.cc (migrate_monotone_schema) + (migrator::migrate): Move the "nothing happened" check, and don't + vacuum unless a migration occurred. + +2005-07-13 Nathaniel Smith + * tests/t_restricted_diff_unchanged.at: New test. * testsuite.at: Add it. --- contrib/ciabot_monotone.py +++ contrib/ciabot_monotone.py @@ -99,6 +99,9 @@ def db_init(self): self._run_monotone(["db", "init"]) + def db_migrate(self): + self._run_monotone(["db", "migrate"]) + def ensure_db_exists(self): if not os.path.exists(self.db): self.db_init() @@ -263,6 +266,7 @@ c = config() m = Monotone(c.monotone_exec, os.path.join(state_dir, "database.db")) m.ensure_db_exists() + m.db_migrate() for server, collection in c.watch_list: m.pull(server, collection) lf = LeafFile(os.path.join(state_dir, "leaves")) --- schema_migration.cc +++ schema_migration.cc @@ -191,11 +191,6 @@ throw runtime_error("NULL sqlite object given to migrate"); calculate_schema_id(sql, init); - if (target_id == init) - { - P(F("nothing to migrate; schema %s is up-to-date\n") % init); - return; - } if (sqlite3_create_function(sql, "sha1", -1, SQLITE_UTF8, NULL, &sqlite_sha1_fn, NULL, NULL)) @@ -259,7 +254,18 @@ { throw runtime_error("failure on COMMIT"); } + + if (sqlite3_exec(sql, "VACUUM", NULL, NULL, NULL) != SQLITE_OK) + throw runtime_error("error vacuuming after migration"); } + else + { + // We really want 'db migrate' on an up-to-date schema to be a no-op + // (no vacuum or anything, even), so that automated scripts can fire + // one off optimistically and not have to worry about getting their + // administrators to do it by hand. + P(F("no migration performed; database schema already up-to-date at %s\n") % init); + } } }; @@ -787,8 +793,4 @@ // tests/t_migrate_schema.at for details. m.migrate(sql, "1509fd75019aebef5ac3da3a5edf1312393b70e9"); - - if (sqlite3_exec(sql, "VACUUM", NULL, NULL, NULL) != SQLITE_OK) - throw runtime_error("error vacuuming after migration"); - }