# # patch "app_state.cc" # from [dae69a1502b8879ada55d439d0563a0c54a9b0cb] # to [ca90cda7eee78c78686f2a9e164ff47c44d3bfd0] # # patch "app_state.hh" # from [c205c128da42a2d24e189244604b6374b200e600] # to [29b3aa9b929488654ae7bd16f5428225a7eb9a7c] # # patch "restrictions.cc" # from [7143bb2882a478cf0c6be8075532bf0733f98f2c] # to [5e937d86146454597d17d378728b942120c5097c] # ======================================================================== --- app_state.cc dae69a1502b8879ada55d439d0563a0c54a9b0cb +++ app_state.cc ca90cda7eee78c78686f2a9e164ff47c44d3bfd0 @@ -186,6 +186,28 @@ } bool +app_state::restriction_requires_parent(split_path const & sp) +{ + file_path path(sp); + if (restrictions.empty()) + return false; + + for (path_set::const_iterator i = restrictions.begin(); + i != restrictions.end(); ++i) + { + // If sp is a parent of any member rs of the restriction, + // we want to return true. + split_path rs = *i; + if (rs.size() < sp.size()) + continue; + rs.resize(sp.size()); + if (rs == sp) + return true; + } + return false; +} + +bool app_state::restriction_includes(split_path const & sp) { // FIXME: this was written before split_path, and only later kludged to ======================================================================== --- app_state.hh c205c128da42a2d24e189244604b6374b200e600 +++ app_state.hh 29b3aa9b929488654ae7bd16f5428225a7eb9a7c @@ -90,6 +90,7 @@ void app_state::set_restriction(path_set const & valid_paths, std::vector const & paths, bool respect_ignore = true); + bool restriction_requires_parent(split_path const & path); bool restriction_includes(split_path const & path); // Set the branch name. If you only invoke set_branch, the branch ======================================================================== --- restrictions.cc 7143bb2882a478cf0c6be8075532bf0733f98f2c +++ restrictions.cc 5e937d86146454597d17d378728b942120c5097c @@ -82,7 +82,18 @@ for (path_set::const_iterator i = cs.dirs_added.begin(); i != cs.dirs_added.end(); ++i) { - if (app.restriction_includes(*i)) + // Here is a trick: when you're dealing with restrictions, you need + // to make sure that any added parents required to make the + // restriction-affected files exist come along for the ride. + bool include_it = app.restriction_includes(*i); + if (!include_it) + { + include_it = app.restriction_requires_parent(*i); + if (include_it) + W(F("Included required parent path '%s'\n") % *i); + } + + if (include_it) safe_insert(included.dirs_added, *i); else safe_insert(excluded.dirs_added, *i);