# # # patch "automate.cc" # from [0e3aa435aad9e048ed08f99e8ebd06c6c8e2ba9e] # to [0850e3e993b5e2df1f1d3c26f3d2086613a2dc52] # # patch "restrictions.cc" # from [9a37177b1a374c1973c01da3d4729e3a5d854453] # to [0d8b88c022f6b67dd2d14fd32f80a4293bb1707b] # # patch "restrictions.hh" # from [d588f4ba6876b51d61d3f37f4836bf2272434310] # to [8108e9bbe2afffcdad1fef41fe329035a76a3a5b] # ============================================================ --- automate.cc 0e3aa435aad9e048ed08f99e8ebd06c6c8e2ba9e +++ automate.cc 0850e3e993b5e2df1f1d3c26f3d2086613a2dc52 @@ -898,7 +898,10 @@ CMD_AUTOMATE(inventory, N_("[PATH]...") node_restriction nmask(includes, excludes, app.opts.depth, old_roster, new_roster, app); inventory_rosters(old_roster, new_roster, nmask, inventory); - path_restriction pmask(includes, excludes, app.opts.depth, app); + // skip the check of the workspace paths because some of them might + // be missing and the user might want to query the recorded structure + // of them anyways + path_restriction pmask(includes, excludes, app.opts.depth, app, path_restriction::skip_check); inventory_filesystem(pmask, inventory, app); basic_io::printer pr; ============================================================ --- restrictions.cc 9a37177b1a374c1973c01da3d4729e3a5d854453 +++ restrictions.cc 0d8b88c022f6b67dd2d14fd32f80a4293bb1707b @@ -72,8 +72,8 @@ static void } static void -validate_roster_paths(set const & included_paths, - set const & excluded_paths, +validate_roster_paths(set const & included_paths, + set const & excluded_paths, set const & known_paths, app_state & app) { @@ -109,7 +109,7 @@ void } void -validate_workspace_paths(set const & included_paths, +validate_workspace_paths(set const & included_paths, set const & excluded_paths, app_state & app) { @@ -118,7 +118,7 @@ validate_workspace_paths(set for (set::const_iterator i = included_paths.begin(); i != included_paths.end(); ++i) { - if (i->empty()) + if (i->empty()) continue; // ignored paths are allowed into the restriction but are not @@ -134,7 +134,7 @@ validate_workspace_paths(set for (set::const_iterator i = excluded_paths.begin(); i != excluded_paths.end(); ++i) { - if (i->empty()) + if (i->empty()) continue; if (!path_exists(*i)) @@ -162,9 +162,9 @@ node_restriction::node_restriction(std:: app_state & a) : restriction(includes, excludes, depth) { - map_nodes(node_map, roster, included_paths, known_paths, + map_nodes(node_map, roster, included_paths, known_paths, restricted_path::included); - map_nodes(node_map, roster, excluded_paths, known_paths, + map_nodes(node_map, roster, excluded_paths, known_paths, restricted_path::excluded); validate_roster_paths(included_paths, excluded_paths, known_paths, a); @@ -178,14 +178,14 @@ node_restriction::node_restriction(std:: app_state & a) : restriction(includes, excludes, depth) { - map_nodes(node_map, roster1, included_paths, known_paths, + map_nodes(node_map, roster1, included_paths, known_paths, restricted_path::included); - map_nodes(node_map, roster1, excluded_paths, known_paths, + map_nodes(node_map, roster1, excluded_paths, known_paths, restricted_path::excluded); - map_nodes(node_map, roster2, included_paths, known_paths, + map_nodes(node_map, roster2, included_paths, known_paths, restricted_path::included); - map_nodes(node_map, roster2, excluded_paths, known_paths, + map_nodes(node_map, roster2, excluded_paths, known_paths, restricted_path::excluded); validate_roster_paths(included_paths, excluded_paths, known_paths, a); @@ -203,15 +203,15 @@ node_restriction::node_restriction(std:: i != rosters1.end(); i++) { - map_nodes(node_map, parent_roster(i), included_paths, known_paths, + map_nodes(node_map, parent_roster(i), included_paths, known_paths, restricted_path::included); - map_nodes(node_map, parent_roster(i), excluded_paths, known_paths, + map_nodes(node_map, parent_roster(i), excluded_paths, known_paths, restricted_path::excluded); } - map_nodes(node_map, roster2, included_paths, known_paths, + map_nodes(node_map, roster2, included_paths, known_paths, restricted_path::included); - map_nodes(node_map, roster2, excluded_paths, known_paths, + map_nodes(node_map, roster2, excluded_paths, known_paths, restricted_path::excluded); validate_roster_paths(included_paths, excluded_paths, known_paths, a); @@ -221,13 +221,17 @@ path_restriction::path_restriction(std:: path_restriction::path_restriction(std::vector const & includes, std::vector const & excludes, long depth, - app_state & a) : + app_state & a, + validity_check vc) : restriction(includes, excludes, depth) { map_paths(path_map, included_paths, restricted_path::included); map_paths(path_map, excluded_paths, restricted_path::excluded); - validate_workspace_paths(included_paths, excluded_paths, a); + if (vc == check_paths) + { + validate_workspace_paths(included_paths, excluded_paths, a); + } } bool @@ -274,7 +278,7 @@ node_restriction::includes(roster_t cons while (!null_node(current) && (depth == -1 || path_depth <= depth + 1)) { - map::const_iterator + map::const_iterator r = node_map.find(current); if (r != node_map.end()) @@ -282,12 +286,12 @@ node_restriction::includes(roster_t cons switch (r->second) { case restricted_path::included: - L(FL("explicit include of nid %d path '%s'") + L(FL("explicit include of nid %d path '%s'") % current % fp); return true; case restricted_path::excluded: - L(FL("explicit exclude of nid %d path '%s'") + L(FL("explicit exclude of nid %d path '%s'") % current % fp); return false; } @@ -300,7 +304,7 @@ node_restriction::includes(roster_t cons if (included_paths.empty()) { - L(FL("default include of nid %d path '%s'") + L(FL("default include of nid %d path '%s'") % nid % fp); return true; } @@ -309,7 +313,7 @@ node_restriction::includes(roster_t cons if (global_sanity.debug_p()) { // printing this slows down "log ". - L(FL("(debug) default exclude of nid %d path '%s'") + L(FL("(debug) default exclude of nid %d path '%s'") % nid % fp); } return false; @@ -352,7 +356,7 @@ path_restriction::includes(file_path con file_path fp = pth; while (depth == -1 || path_depth <= depth + 1) { - map::const_iterator + map::const_iterator r = path_map.find(fp); if (r != path_map.end()) @@ -902,7 +906,7 @@ UNIT_TEST(restrictions, invalid_roster_p excludes.push_back(file_path_internal("bar")); app_state app; - UNIT_TEST_CHECK_THROW(node_restriction(includes, excludes, -1, roster, app), + UNIT_TEST_CHECK_THROW(node_restriction(includes, excludes, -1, roster, app), informative_failure); } @@ -920,6 +924,22 @@ UNIT_TEST(restrictions, invalid_workspac informative_failure); } +UNIT_TEST(restrictions, ignored_invalid_workspace_paths) +{ + roster_t roster; + setup(roster); + + vector includes, excludes; + includes.push_back(file_path_internal("foo")); + excludes.push_back(file_path_internal("bar")); + + app_state app; + path_restriction(includes, excludes, -1, app, path_restriction::skip_check); + + UNIT_TEST_CHECK(pmask.includes(file_path_internal("foo"))); + UNIT_TEST_CHECK(pmask.excludes(file_path_internal("bar"))); +} + UNIT_TEST(restrictions, include_depth_0) { roster_t roster; ============================================================ --- restrictions.hh d588f4ba6876b51d61d3f37f4836bf2272434310 +++ restrictions.hh 8108e9bbe2afffcdad1fef41fe329035a76a3a5b @@ -51,7 +51,7 @@ class app_state; // // revision A ... included ... revision X ... excluded ... revision B -namespace restricted_path +namespace restricted_path { enum status { included, excluded }; } @@ -117,12 +117,15 @@ class path_restriction : public restrict class path_restriction : public restriction { public: + enum validity_check { check_paths = 0, skip_check }; + path_restriction() : restriction() {} path_restriction(std::vector const & includes, std::vector const & excludes, long depth, - app_state & a); + app_state & a, + validity_check vc = check_paths); bool includes(file_path const & sp) const;