# # # add_dir "tests/fail_cleanly_when__MTN_format_empty" # # add_file "tests/fail_cleanly_when__MTN_format_empty/__driver__.lua" # content [4d10c59e800bb90f6a9fdff14979f0ee5ea79370] # # patch "ChangeLog" # from [e045620c7402959fff65fd109f40b91a7e8d4684] # to [902caff280e42273c56a78b29ae579be99d9c664] # # patch "testsuite.lua" # from [f7195efbd96795a3cb57484cbfb69adf258ef881] # to [ff862762e8aca8a44969af17224e0ba6737569c8] # # patch "work_migration.cc" # from [dc1cd438a54cb324bf17ed6a879b1337f9e6bde5] # to [cfc359b2ea7f152cbff71afd2a266c08b6ff539f] # ============================================================ --- tests/fail_cleanly_when__MTN_format_empty/__driver__.lua 4d10c59e800bb90f6a9fdff14979f0ee5ea79370 +++ tests/fail_cleanly_when__MTN_format_empty/__driver__.lua 4d10c59e800bb90f6a9fdff14979f0ee5ea79370 @@ -0,0 +1,9 @@ + +mtn_setup() + +addfile("foo", "blah blah") +commit() + +remove("_MTN/format") +writefile("_MTN/format", "") +check(raw_mtn("status"), 1, false, false) ============================================================ --- ChangeLog e045620c7402959fff65fd109f40b91a7e8d4684 +++ ChangeLog 902caff280e42273c56a78b29ae579be99d9c664 @@ -1,3 +1,9 @@ +2006-12-15 Tero Koskinen + + * work_migration.cc (get_ws_format): Fail cleanly when _MTN/format + is broken. + * tests/fail_cleanly_when__MTN_format_empty: Test. + 2006-12-13 Thomas Moschny * options.cc (name): Call localize_monotone() before fetching an ============================================================ --- testsuite.lua f7195efbd96795a3cb57484cbfb69adf258ef881 +++ testsuite.lua ff862762e8aca8a44969af17224e0ba6737569c8 @@ -695,4 +695,5 @@ table.insert(tests, "mkdir") table.insert(tests, "netsync_permissions_wildcards") table.insert(tests, "log_--to") table.insert(tests, "mkdir") +table.insert(tests, "fail_cleanly_when__MTN_format_empty") ============================================================ --- work_migration.cc dc1cd438a54cb324bf17ed6a879b1337f9e6bde5 +++ work_migration.cc cfc359b2ea7f152cbff71afd2a266c08b6ff539f @@ -64,8 +64,16 @@ get_ws_format() else { data f_dat; - read_data(f_path, f_dat); - format = lexical_cast(remove_ws(f_dat())); + try + { + read_data(f_path, f_dat); + format = lexical_cast(remove_ws(f_dat())); + } + catch (exception & e) + { + E(false, F("workspace is corrupt: %s is invalid") + % f_path); + } if (format == 1) { W(F("_MTN/format should not exist in a format 1 workspace; corrected"));