# # # add_dir "tests/missing_empty_dir" # # add_file "tests/missing_empty_dir/__driver__.lua" # content [852bbd4441b9b858223f48074a6763fc644ada95] # # patch "ChangeLog" # from [fc2c4966f8154496d3147cc7ece78e09d3f35294] # to [7b487b83eaa842ff43e35aa2ab0510c1253a0b90] # # patch "testsuite.lua" # from [528db1ed137b479e223d9830d535348e677fb216] # to [d3183be3af86c27e3c66dd069726de3ee97e5f2d] # # patch "work.cc" # from [aa552b8a8355ad6c7c39921004f5026535a10345] # to [dae8df9b29388a8c016ac5c421c79decf8572247] # ============================================================ --- tests/missing_empty_dir/__driver__.lua 852bbd4441b9b858223f48074a6763fc644ada95 +++ tests/missing_empty_dir/__driver__.lua 852bbd4441b9b858223f48074a6763fc644ada95 @@ -0,0 +1,18 @@ + +mtn_setup() + +mkdir("foo") +mkdir("bar") + +check(mtn("add", "foo"), 0, false, true) +check(mtn("add", "bar"), 0, false, true) +commit() + +remove("foo") + +check(mtn("status"), 1, false, false) + +writefile("foo", "foo") + +check(mtn("status"), 1, false, false) + ============================================================ --- ChangeLog fc2c4966f8154496d3147cc7ece78e09d3f35294 +++ ChangeLog 7b487b83eaa842ff43e35aa2ab0510c1253a0b90 @@ -1,3 +1,14 @@ +2006-12-28 Derek Scherger + + * tests/missing_empty_dir/__driver__.lua: new test for missing, + empty, versioned directories + * testsuite.lua: call it + * work.cc (update_current_roster_from_filesystem): abort if there + are missing directories, whether they contained files or + not. tweak the associated messages so they're a bit more specific + about missing things verses things that are not what they should + be, like files that should be directories and vice-versa. + 2006-12-27 Richard Levitte * NEWS: Date the release. ============================================================ --- testsuite.lua 528db1ed137b479e223d9830d535348e677fb216 +++ testsuite.lua d3183be3af86c27e3c66dd069726de3ee97e5f2d @@ -697,4 +697,5 @@ table.insert(tests, "add_ignores__MTN") table.insert(tests, "mkdir") table.insert(tests, "fail_cleanly_when__MTN_format_corrupt") table.insert(tests, "add_ignores__MTN") +table.insert(tests, "missing_empty_dir") ============================================================ --- work.cc aa552b8a8355ad6c7c39921004f5026535a10345 +++ work.cc dae8df9b29388a8c016ac5c421c79decf8572247 @@ -946,7 +946,7 @@ workspace::update_current_roster_from_fi read_inodeprint_map(dat, ipm); } - size_t missing_files = 0; + size_t missing_items = 0; // this code is speed critical, hence the use of inode fingerprints so be // careful when making changes in here and preferably do some timing tests @@ -960,11 +960,7 @@ workspace::update_current_roster_from_fi node_id nid = i->first; node_t node = i->second; - // Only analyze files further, not dirs. - if (! is_file_t(node)) - continue; - - // Only analyze restriction-included files. + // Only analyze restriction-included files and dirs if (!mask.includes(ros, nid)) continue; @@ -972,28 +968,52 @@ workspace::update_current_roster_from_fi ros.get_name(nid, sp); file_path fp(sp); - // Only analyze changed files (or all files if inodeprints mode - // is disabled). - if (inodeprint_unchanged(ipm, fp)) - continue; - - file_t file = downcast_to_file_t(node); - if (!ident_existing_file(fp, file->content, lua)) + if (is_dir_t(node)) { - W(F("missing %s") % (fp)); - missing_files++; + if (!path_exists(fp)) + { + W(F("missing directory '%s'") % (fp)); + missing_items++; + } + else if (!directory_exists(fp)) + { + W(F("not a directory '%s'") % (fp)); + missing_items++; + } } + else + { + // Only analyze changed files (or all files if inodeprints mode + // is disabled). + if (inodeprint_unchanged(ipm, fp)) + continue; + + if (!path_exists(fp)) + { + W(F("missing file '%s'") % (fp)); + missing_items++; + } + else if (!file_exists(fp)) + { + W(F("not a file '%s'") % (fp)); + missing_items++; + } + + file_t file = downcast_to_file_t(node); + ident_existing_file(fp, file->content, lua); + } + } - N(missing_files == 0, - F("%d missing files; use '%s ls missing' to view\n" - "To restore consistency, on each missing file run either\n" - " '%s drop FILE' to remove it permanently, or\n" - " '%s revert FILE' to restore it.\n" + N(missing_items == 0, + F("%d missing items; use '%s ls missing' to view\n" + "To restore consistency, on each missing item run either\n" + " '%s drop ITEM' to remove it permanently, or\n" + " '%s revert ITEM' to restore it.\n" "To handle all at once, simply use\n" " '%s drop --missing' or\n" " '%s revert --missing'") - % missing_files % ui.prog_name % ui.prog_name % ui.prog_name + % missing_items % ui.prog_name % ui.prog_name % ui.prog_name % ui.prog_name % ui.prog_name); }