#
#
# patch "ChangeLog"
# from [0955d776c91093b8260a4f2fd5fb4e1ca23c880a]
# to [e661d96285a0c54c6dd981314e3728edb0687cf3]
#
# patch "database.cc"
# from [b682d2155d6293546402decc6f96e723bd18d7dc]
# to [db1989a440fae91e066e3168c776af078ab531e8]
#
# patch "database.hh"
# from [bbf8e39a0adaa28a4694549d26602b3712f6109c]
# to [df8da3f0b1c8995d1e4e64200a13b26200b1d767]
#
# patch "schema_migration.cc"
# from [68292293578bfaa6f996002650d4ffe13a29d216]
# to [e1ea1f91c0830784152e630beb42a16a601d2a52]
#
# patch "schema_migration.hh"
# from [c6044b2d2db646eb8b2a89fabc01d0ef869cc92a]
# to [c5297d15ee9dfa8b96cb01a96cd6a811d80ef97c]
#
============================================================
--- ChangeLog 0955d776c91093b8260a4f2fd5fb4e1ca23c880a
+++ ChangeLog e661d96285a0c54c6dd981314e3728edb0687cf3
@@ -1,5 +1,24 @@ 2007-01-09 Zack Weinberg
+ * schema_migration.cc: Prune headers and using-declarations. Make
+ various things static and/or wrapped in the anonymous namespace.
+ (struct migrator): Delete.
+ (migrator_cb): Move definition to just above first use.
+ (struct migration_event, migration_events, n_migration_events)
+ (schema_to_migration, diagnose_unrecognized_schema, check_sql_schema):
+ New functions and data.
+ (migrate_monotone_schema): Put all the logic that used to be in
+ migrator::migrate here instead. Use two loops instead of one loop
+ and a state boolean, for clarity.
+ * schema_migration.hh: Prune headers. Forward-declare system_path.
+ Declare check_sql_schema. Adjust spacing.
+ * database.cc (database::database): Delete initialization of "schema".
+ (database::check_schema, close_all_databases): Delete.
+ (database::sql): Call check_sql_schema instead of check_schema.
+ * database.hh (database): Remove "schema" data-member and
+ check_schema function-member.
+ (close_all_databases): Delete declaration.
+
* transforms.hh (xform): Make the generic template produce a
compile error if instantiated. Use standard declarations of
partial specializations for the usable cases of xform, not the g++
============================================================
--- database.cc b682d2155d6293546402decc6f96e723bd18d7dc
+++ database.cc db1989a440fae91e066e3168c776af078ab531e8
@@ -127,13 +127,7 @@ database::database(system_path const & f
database::database(system_path const & fn) :
filename(fn),
- // nb. update this if you change the schema. unfortunately we are not
- // using self-digesting schemas due to comment irregularities and
- // non-alphabetic ordering of tables in sql source files. we could create
- // a temporary db, write our intended schema into it, and read it back,
- // but this seems like it would be too rude. possibly revisit this issue.
__sql(NULL),
- schema("48fd5d84f1e5a949ca093e87e5ac558da6e5956d"),
transaction_level(0),
roster_cache(constants::db_roster_cache_sz,
roster_writeback_manager(*this)),
@@ -151,19 +145,6 @@ void
}
void
-database::check_schema()
-{
- string db_schema_id;
- calculate_schema_id (__sql, db_schema_id);
- N (schema == db_schema_id,
- F("layout of database %s doesn't match this version of monotone\n"
- "wanted schema %s, got %s\n"
- "try '%s db migrate' to upgrade\n"
- "(this is irreversible; you may want to make a backup copy first)")
- % filename % schema % db_schema_id % ui.prog_name);
-}
-
-void
database::check_is_not_rosterified()
{
results res;
@@ -318,7 +299,7 @@ database::sql(bool init, bool migrating_
assert_sqlite3_ok(__sql);
}
- check_schema();
+ check_sql_schema(__sql, filename);
install_functions(__app);
if (!migrating_format)
@@ -3135,27 +3116,6 @@ transaction_guard::commit()
committed = true;
}
-
-
-// called to avoid foo.db-journal files hanging around if we exit cleanly
-// without unwinding the stack (happens with SIGINT & SIGTERM)
-void
-close_all_databases()
-{
- L(FL("attempting to rollback and close %d databases") % sql_contexts.size());
- for (set::iterator i = sql_contexts.begin();
- i != sql_contexts.end(); i++)
- {
- // the ROLLBACK is required here, even though the sqlite docs
- // imply that transactions are rolled back on database closure
- int exec_err = sqlite3_exec(*i, "ROLLBACK", NULL, NULL, NULL);
- int close_err = sqlite3_close(*i);
-
- L(FL("exec_err = %d, close_err = %d") % exec_err % close_err);
- }
- sql_contexts.clear();
-}
-
// Local Variables:
// mode: C++
// fill-column: 76
============================================================
--- database.hh bbf8e39a0adaa28a4694549d26602b3712f6109c
+++ database.hh df8da3f0b1c8995d1e4e64200a13b26200b1d767
@@ -97,8 +97,6 @@ private:
void open();
void close();
- std::string const schema;
- void check_schema();
void check_format();
public:
@@ -624,11 +622,6 @@ public:
void commit();
};
-
-void
-close_all_databases();
-
-
// Local Variables:
// mode: C++
// fill-column: 76
============================================================
--- schema_migration.cc 68292293578bfaa6f996002650d4ffe13a29d216
+++ schema_migration.cc e1ea1f91c0830784152e630beb42a16a601d2a52
@@ -7,21 +7,12 @@
// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE.
-#include
-#include
-#include
-#include
-#include
-#include
-#include