# # # patch "database.cc" # from [b3af3d4a28c233d0bb47d6a3d0b5d7c5a63918ed] # to [293bd9d6733f072957e866c8daeaaff11ae962b2] # # patch "database.hh" # from [a2cdd91a834be480b4567a0c713f8e88a6f8a788] # to [8f1965d29d5a74b5581740d69f6291bdd71def51] # ============================================================ --- database.cc b3af3d4a28c233d0bb47d6a3d0b5d7c5a63918ed +++ database.cc 293bd9d6733f072957e866c8daeaaff11ae962b2 @@ -93,6 +93,25 @@ % filename % schema % db_schema_id); } +void +database::check_rosterified() +{ + results res; + string rosters_query = "SELECT 1 FROM rosters LIMIT 1"; + string revisions_query = "SELECT 1 FROM revisions LIMIT 1"; + + fetch(res, one_col, any_rows, revisions_query.c_str()); + if (res.size() > 0) + { + fetch(res, one_col, any_rows, rosters_query.c_str()); + N (res.size() != 0, + F("database %s contains revisions but no rosters\n" + "try 'monotone db rosterify' to add rosters\n" + "(this is irreversible; you may want to make a backup copy first)") + % filename); + } +} + // sqlite3_value_text gives a const unsigned char * but most of the time // we need a signed char const char * @@ -2660,8 +2679,13 @@ results res; string query = ("SELECT roster_id FROM revision_roster WHERE rev_id = ? "); - fetch(res, one_col, one_row, query.c_str(), + fetch(res, one_col, any_rows, query.c_str(), rev_id.inner()().c_str()); + if (res.size() == 0) + { + check_rosterified(); + } + I(res.size() == 1); roster_id = hexenc(res[0][0]); } ============================================================ --- database.hh a2cdd91a834be480b4567a0c713f8e88a6f8a788 +++ database.hh 8f1965d29d5a74b5581740d69f6291bdd71def51 @@ -76,6 +76,7 @@ system_path filename; std::string const schema; void check_schema(); + void check_rosterified(); struct statement { statement() : count(0), stmt(0, sqlite3_finalize) {}