#
#
# patch "ChangeLog"
# from [82c6f9e4c25f6e757736fefc927a690a6288ecdd]
# to [42052f91c94cc8e494c2ac02fc2827a3b4893399]
#
# patch "automate.cc"
# from [3929e91b407cc9896673a9eed9ca77375646922f]
# to [a7c783cc9b6edbcb7361be8bc68619e215321aa0]
#
# patch "commands.cc"
# from [382a8cbc66504ad926163303f64099eb58acd582]
# to [cb69d758a217fd43d8cfe36d37ad37979f90b298]
#
# patch "restrictions.cc"
# from [393a97c027623507475fb0087dcda4f16b03ce86]
# to [fc4fb9645fc05eaab15ef5b1f7c7711e66142877]
#
# patch "restrictions.hh"
# from [8d68ee9d4981f22f01ecf499602fcbc7b6d4b6fe]
# to [54a5faec54b44ad6dec5ac9aa7854467331181e6]
#
# patch "roster.cc"
# from [e5c5a7e458a6f7e8680f7f11052f3ffa9ae8714d]
# to [91d762446711f8f866dc64341f0a24e14638a871]
#
# patch "tests/t_automate_get_manifest_of.at"
# from [d9c77a0178966dc2299c8fd72dffa6147a4bb494]
# to [edc1cee6363259bbb70e4c0f6b2fb0ec0b7f6f1b]
#
# patch "tests/t_restrictions.at"
# from [ca23ce3a30758abad47e9919544b743130bb66de]
# to [c3da9d248652641bdee32e01a7a91424035de387]
#
============================================================
--- ChangeLog 82c6f9e4c25f6e757736fefc927a690a6288ecdd
+++ ChangeLog 42052f91c94cc8e494c2ac02fc2827a3b4893399
@@ -1,3 +1,17 @@
+2006-02-25 Derek Scherger
+
+ * automate.cc (automate_inventory):
+ * commands.cc (status, ls_known, find_unknown_and_ignored,
+ find_missing, ls_changed, commit, diff, revert, log):
+ * roster.cc (update_current_roster_from_filesystem): add app_state
+ to restriction constructors
+ * restrictions.{cc,hh}: add support for --depth option and ignored
+ files in restrictions to match old functionality; clean up
+ constructors a bit
+ * tests/t_automate_get_manifest_of.at: add format_version stanza
+ to test manifest
+ * tests/t_restrictions.at: re-enable --depth tests
+
2006-02-22 Derek Scherger
* automate.cc (automate_get_revision, automate_get_manifest_of):
============================================================
--- automate.cc 3929e91b407cc9896673a9eed9ca77375646922f
+++ automate.cc a7c783cc9b6edbcb7361be8bc68619e215321aa0
@@ -707,7 +707,7 @@
classify_roster_paths(curr, unchanged, changed, missing, app);
curr.extract_path_set(known);
- restriction mask;
+ restriction mask(app);
file_itemizer u(app, known, unknown, ignored, mask);
walk_tree(file_path(), u);
============================================================
--- commands.cc 382a8cbc66504ad926163303f64099eb58acd582
+++ commands.cc cb69d758a217fd43d8cfe36d37ad37979f90b298
@@ -1303,7 +1303,7 @@
app.require_workspace();
get_base_and_current_roster_shape(old_roster, new_roster, app);
- restriction mask(args, app.exclude_patterns, old_roster, new_roster);
+ restriction mask(args, app.exclude_patterns, old_roster, new_roster, app);
update_current_roster_from_filesystem(new_roster, mask, app);
make_restricted_csets(old_roster, new_roster, included, excluded, mask);
@@ -1666,7 +1666,7 @@
app.require_workspace();
get_base_and_current_roster_shape(old_roster, new_roster, app);
- restriction mask(args, app.exclude_patterns, new_roster);
+ restriction mask(args, app.exclude_patterns, new_roster, app);
node_map const & nodes = new_roster.all_nodes();
for (node_map::const_iterator i = nodes.begin(); i != nodes.end(); ++i)
@@ -1694,7 +1694,7 @@
get_base_and_current_roster_shape(old_roster, new_roster, app);
- restriction mask(args, app.exclude_patterns, new_roster);
+ restriction mask(args, app.exclude_patterns, old_roster, new_roster, app);
new_roster.extract_path_set(known);
@@ -1727,7 +1727,7 @@
get_base_and_current_roster_shape(old_roster, new_roster, app);
- restriction mask(args, app.exclude_patterns, new_roster);
+ restriction mask(args, app.exclude_patterns, new_roster, app);
node_map const & nodes = new_roster.all_nodes();
for (node_map::const_iterator i = nodes.begin(); i != nodes.end(); ++i)
@@ -1779,12 +1779,15 @@
get_base_and_current_roster_shape(old_roster, new_roster, app);
- restriction mask(args, app.exclude_patterns, old_roster, new_roster);
+ restriction mask(args, app.exclude_patterns, old_roster, new_roster, app);
update_current_roster_from_filesystem(new_roster, mask, app);
make_restricted_csets(old_roster, new_roster, included, excluded, mask);
// FIXME: this would probably be better as a function of roster.cc
+ // set nodes;
+ // select_nodes_modified_by_cset(included, old_roster, new_roster, nodes);
+
for (path_set::const_iterator i = included.nodes_deleted.begin();
i != included.nodes_deleted.end(); ++i)
{
@@ -2384,7 +2387,7 @@
app.require_workspace();
get_base_and_current_roster_shape(old_roster, new_roster, app);
- restriction mask(args, app.exclude_patterns, old_roster, new_roster);
+ restriction mask(args, app.exclude_patterns, old_roster, new_roster, app);
update_current_roster_from_filesystem(new_roster, mask, app);
make_restricted_csets(old_roster, new_roster, included, excluded, mask);
@@ -2786,7 +2789,7 @@
get_base_and_current_roster_shape(old_roster, new_roster, app);
get_revision_id(old_rid);
- restriction mask(args, app.exclude_patterns, old_roster, new_roster);
+ restriction mask(args, app.exclude_patterns, old_roster, new_roster, app);
update_current_roster_from_filesystem(new_roster, mask, app);
make_restricted_csets(old_roster, new_roster, included, excluded, mask);
@@ -2810,7 +2813,7 @@
// FIXME: handle no ancestor case
// N(r_new.edges.size() == 1, F("current revision has no ancestor"));
- restriction mask(args, app.exclude_patterns, old_roster, new_roster);
+ restriction mask(args, app.exclude_patterns, old_roster, new_roster, app);
update_current_roster_from_filesystem(new_roster, mask, app);
make_restricted_csets(old_roster, new_roster, included, excluded, mask);
@@ -2834,7 +2837,7 @@
app.db.get_roster(r_old_id, old_roster);
app.db.get_roster(r_new_id, new_roster);
- restriction mask(args, app.exclude_patterns, old_roster, new_roster);
+ restriction mask(args, app.exclude_patterns, old_roster, new_roster, app);
// FIXME: this is *possibly* a UI bug, insofar as we
// look at the restriction name(s) you provided on the command
@@ -3398,7 +3401,7 @@
}
get_base_and_current_roster_shape(old_roster, new_roster, app);
- restriction mask(includes, excludes, old_roster, new_roster);
+ restriction mask(includes, excludes, old_roster, new_roster, app);
make_restricted_csets(old_roster, new_roster, included, excluded, mask);
@@ -3610,7 +3613,7 @@
}
}
- restriction mask;
+ restriction mask(app);
if (args.size() > 0)
{
@@ -3623,8 +3626,8 @@
app.db.get_roster(first_rid, new_roster);
// FIXME_RESTRICTIONS: should this add paths from the rosters of all selected revs?
-
- mask = restriction(args, app.exclude_patterns, old_roster, new_roster);
+ // try log dir/ to see what happens
+ mask = restriction(args, app.exclude_patterns, old_roster, new_roster, app);
}
cert_name author_name(author_cert_name);
============================================================
--- restrictions.cc 393a97c027623507475fb0087dcda4f16b03ce86
+++ restrictions.cc fc4fb9645fc05eaab15ef5b1f7c7711e66142877
@@ -71,7 +71,9 @@
// FIXME: should we really be doing implicit includes of parents?
static void
-get_parent_nodes(set const & nodes, roster_t const & roster, set & parents)
+get_parent_nodes(set const & nodes,
+ roster_t const & roster,
+ set & parents)
{
for (set::const_iterator i = nodes.begin(); i != nodes.end(); ++i)
{
@@ -123,7 +125,9 @@
}
static void
-add_paths(map & path_map, path_set const & paths, path_state const state)
+add_paths(map & path_map,
+ path_set const & paths,
+ path_state const state)
{
for (path_set::const_iterator i = paths.begin(); i != paths.end(); ++i)
{
@@ -167,51 +171,71 @@
}
}
-static void
-add_paths(map & path_map,
- path_set const & includes,
- path_set const & excludes)
+////////////////////////////////////////////////////////////////////////////////
+// construction helpers
+////////////////////////////////////////////////////////////////////////////////
+
+void
+restriction::map_paths(vector const & include_args,
+ vector const & exclude_args)
{
- path_set parents;
- get_parent_paths(includes, parents);
+ make_path_set(include_args, included_paths);
+ make_path_set(exclude_args, excluded_paths);
- add_paths(path_map, includes, explicit_include);
- add_paths(path_map, excludes, explicit_exclude);
- add_paths(path_map, parents, implicit_include);
+ path_set parent_paths;
+ get_parent_paths(included_paths, parent_paths);
+
+ add_paths(path_map, included_paths, explicit_include);
+ add_paths(path_map, excluded_paths, explicit_exclude);
+ add_paths(path_map, parent_paths, implicit_include);
+
+ L(FL("restriction paths: %d included; %d excluded; %d parents")
+ % included_paths.size()
+ % excluded_paths.size()
+ % parent_paths.size());
}
-static void
-add_nodes(map & node_map,
- roster_t const & roster,
- path_set const & includes,
- path_set const & excludes,
- path_set & known_paths)
+void
+restriction::map_nodes(roster_t const & roster)
{
set included_nodes, excluded_nodes, parent_nodes;
- get_nodes(includes, roster, included_nodes, known_paths);
- get_nodes(excludes, roster, excluded_nodes, known_paths);
+ get_nodes(included_paths, roster, included_nodes, known_paths);
+ get_nodes(excluded_paths, roster, excluded_nodes, known_paths);
get_parent_nodes(included_nodes, roster, parent_nodes);
add_nodes(node_map, roster, included_nodes, explicit_include);
add_nodes(node_map, roster, excluded_nodes, explicit_exclude);
add_nodes(node_map, roster, parent_nodes, implicit_include);
+
+ L(FL("restriction nodes: %d included; %d excluded; %d parents")
+ % included_nodes.size()
+ % excluded_nodes.size()
+ % parent_nodes.size());
}
-static void
-check_paths(path_set const & includes, path_set const & excludes, path_set const & known_paths)
+void
+restriction::validate()
{
int bad = 0;
- for (path_set::const_iterator i = includes.begin(); i != includes.end(); ++i)
+ for (path_set::const_iterator i = included_paths.begin();
+ i != included_paths.end(); ++i)
{
+ // ignored paths are allowed into the restriction but are not considered
+ // invalid if they are found in none of the restriction's rosters
if (known_paths.find(*i) == known_paths.end())
{
- bad++;
- W(F("unknown path included %s") % *i);
+ file_path fp(*i);
+ if (!app.lua.hook_ignore_file(fp))
+ {
+ bad++;
+ W(F("unknown path included %s") % *i);
+ }
}
}
- for (path_set::const_iterator i = excludes.begin(); i != excludes.end(); ++i)
+ for (path_set::const_iterator i = excluded_paths.begin();
+ i != excluded_paths.end(); ++i)
{
if (known_paths.find(*i) == known_paths.end())
{
@@ -224,44 +248,6 @@
}
////////////////////////////////////////////////////////////////////////////////
-// public constructors
-////////////////////////////////////////////////////////////////////////////////
-
-restriction::restriction(vector const & include_args,
- vector const & exclude_args,
- roster_t const & roster)
-{
- path_set includes, excludes, known_paths;
- make_path_set(include_args, includes);
- make_path_set(exclude_args, excludes);
-
- add_paths(path_map, includes, excludes);
- add_nodes(node_map, roster, includes, excludes, known_paths);
-
- default_result = includes.empty();
-
- check_paths(includes, excludes, known_paths);
-}
-
-restriction::restriction(vector const & include_args,
- vector const & exclude_args,
- roster_t const & roster1,
- roster_t const & roster2)
-{
- path_set includes, excludes, known_paths;
- make_path_set(include_args, includes);
- make_path_set(exclude_args, excludes);
-
- add_paths(path_map, includes, excludes);
- add_nodes(node_map, roster1, includes, excludes, known_paths);
- add_nodes(node_map, roster2, includes, excludes, known_paths);
-
- default_result = includes.empty();
-
- check_paths(includes, excludes, known_paths);
-}
-
-////////////////////////////////////////////////////////////////////////////////
// public api
////////////////////////////////////////////////////////////////////////////////
@@ -275,15 +261,20 @@
roster.get_name(nid, sp);
// empty restriction includes everything
- if (node_map.empty())
+ if (empty())
{
L(FL("empty include of nid %d path '%s'") % nid % file_path(sp));
return true;
}
node_id current = nid;
+ int depth = 0;
- while (!null_node(current))
+ // use app.depth+1 here because the old semantics of depth=0 were something
+ // like "the current directory and its immediate children". it seems somewhat
+ // more reasonable here to use depth=0 to mean "exactly this directory" and
+ // depth=1 to mean "this directory and its immediate children"
+ while (!null_node(current) && (app.depth == -1 || depth <= app.depth + 1))
{
map::const_iterator r = node_map.find(current);
@@ -301,7 +292,7 @@
case implicit_include:
// this is non-recursive and requires an exact match
- if (current == nid)
+ if (depth == 0)
{
L(FL("implicit include of nid %d path '%s'") % current % file_path(sp));
return true;
@@ -311,9 +302,10 @@
node_t node = roster.get_node(current);
current = node->parent;
+ depth++;
}
- if (default_result)
+ if (included_paths.empty())
{
L(FL("default include of nid %d path '%s'\n") % nid % file_path(sp));
return true;
@@ -328,15 +320,21 @@
bool
restriction::includes(split_path const & sp) const
{
- if (path_map.empty())
+ // empty restriction includes everything
+ if (empty())
{
L(FL("empty include of path '%s'") % file_path(sp));
return true;
}
split_path current(sp);
+ int depth = 0;
- while (!current.empty())
+ // use app.depth+1 here because the old semantics of depth=0 were something
+ // like "the current directory and its immediate children". it seems somewhat
+ // more reasonable here to use depth=0 to mean "exactly this directory" and
+ // depth=1 to mean "this directory and its immediate children"
+ while (!current.empty() && (app.depth == -1 || depth <= app.depth + 1))
{
map::const_iterator r = path_map.find(current);
@@ -354,7 +352,7 @@
case implicit_include:
// this is non-recursive and requires an exact match
- if (current == sp)
+ if (depth == 0)
{
L(FL("implicit include of path '%s'") % file_path(sp));
return true;
@@ -363,9 +361,10 @@
}
current.pop_back();
+ depth++;
}
- if (default_result)
+ if (included_paths.empty())
{
L(FL("default include of path '%s'\n") % file_path(sp));
return true;
@@ -382,6 +381,7 @@
////////////////////////////////////////////////////////////////////////////////
#ifdef BUILD_UNIT_TESTS
+#include "app_state.hh"
#include "unit_tests.hh"
#include "roster.hh"
#include "sanity.hh"
@@ -540,7 +540,8 @@
roster_t roster;
setup(roster);
- restriction mask;
+ app_state app;
+ restriction mask(app);
BOOST_CHECK(mask.empty());
@@ -605,7 +606,8 @@
includes.push_back(utf8(string("x/x")));
includes.push_back(utf8(string("y/y")));
- restriction mask(includes, excludes, roster);
+ app_state app;
+ restriction mask(includes, excludes, roster, app);
BOOST_CHECK(!mask.empty());
@@ -670,7 +672,8 @@
excludes.push_back(utf8(string("x/x")));
excludes.push_back(utf8(string("y/y")));
- restriction mask(includes, excludes, roster);
+ app_state app;
+ restriction mask(includes, excludes, roster, app);
BOOST_CHECK(!mask.empty());
@@ -737,7 +740,8 @@
excludes.push_back(utf8(string("x/x")));
excludes.push_back(utf8(string("y/y")));
- restriction mask(includes, excludes, roster);
+ app_state app;
+ restriction mask(includes, excludes, roster, app);
BOOST_CHECK(!mask.empty());
@@ -804,7 +808,8 @@
includes.push_back(utf8(string("x/x")));
includes.push_back(utf8(string("y/y")));
- restriction mask(includes, excludes, roster);
+ app_state app;
+ restriction mask(includes, excludes, roster, app);
BOOST_CHECK(!mask.empty());
@@ -869,7 +874,8 @@
includes.push_back(utf8(string("foo")));
excludes.push_back(utf8(string("bar")));
- BOOST_CHECK_THROW(restriction(includes, excludes, roster), informative_failure);
+ app_state app;
+ BOOST_CHECK_THROW(restriction(includes, excludes, roster, app), informative_failure);
}
static void
@@ -890,6 +896,140 @@
BOOST_CHECK(parents.find(abc) == parents.end());
}
+static void
+test_include_depth_0()
+{
+ roster_t roster;
+ setup(roster);
+
+ vector includes, excludes;
+ includes.push_back(utf8(string("x")));
+ includes.push_back(utf8(string("y")));
+
+ app_state app;
+ app.set_depth(0);
+ restriction mask(includes, excludes, roster, app);
+
+ BOOST_CHECK(!mask.empty());
+
+ // check restricted nodes
+ BOOST_CHECK( mask.includes(roster, nid_root));
+ BOOST_CHECK(!mask.includes(roster, nid_f));
+ BOOST_CHECK(!mask.includes(roster, nid_g));
+
+ BOOST_CHECK( mask.includes(roster, nid_x));
+ BOOST_CHECK(!mask.includes(roster, nid_xf));
+ BOOST_CHECK(!mask.includes(roster, nid_xg));
+ BOOST_CHECK(!mask.includes(roster, nid_xx));
+ BOOST_CHECK(!mask.includes(roster, nid_xxf));
+ BOOST_CHECK(!mask.includes(roster, nid_xxg));
+ BOOST_CHECK(!mask.includes(roster, nid_xy));
+ BOOST_CHECK(!mask.includes(roster, nid_xyf));
+ BOOST_CHECK(!mask.includes(roster, nid_xyg));
+
+ BOOST_CHECK( mask.includes(roster, nid_y));
+ BOOST_CHECK(!mask.includes(roster, nid_yf));
+ BOOST_CHECK(!mask.includes(roster, nid_yg));
+ BOOST_CHECK(!mask.includes(roster, nid_yx));
+ BOOST_CHECK(!mask.includes(roster, nid_yxf));
+ BOOST_CHECK(!mask.includes(roster, nid_yxg));
+ BOOST_CHECK(!mask.includes(roster, nid_yy));
+ BOOST_CHECK(!mask.includes(roster, nid_yyf));
+ BOOST_CHECK(!mask.includes(roster, nid_yyg));
+
+ // check restricted paths
+ BOOST_CHECK( mask.includes(sp_root));
+ BOOST_CHECK(!mask.includes(sp_f));
+ BOOST_CHECK(!mask.includes(sp_g));
+
+ BOOST_CHECK( mask.includes(sp_x));
+ BOOST_CHECK(!mask.includes(sp_xf));
+ BOOST_CHECK(!mask.includes(sp_xg));
+ BOOST_CHECK(!mask.includes(sp_xx));
+ BOOST_CHECK(!mask.includes(sp_xxf));
+ BOOST_CHECK(!mask.includes(sp_xxg));
+ BOOST_CHECK(!mask.includes(sp_xy));
+ BOOST_CHECK(!mask.includes(sp_xyf));
+ BOOST_CHECK(!mask.includes(sp_xyg));
+
+ BOOST_CHECK( mask.includes(sp_y));
+ BOOST_CHECK(!mask.includes(sp_yf));
+ BOOST_CHECK(!mask.includes(sp_yg));
+ BOOST_CHECK(!mask.includes(sp_yx));
+ BOOST_CHECK(!mask.includes(sp_yxf));
+ BOOST_CHECK(!mask.includes(sp_yxg));
+ BOOST_CHECK(!mask.includes(sp_yy));
+ BOOST_CHECK(!mask.includes(sp_yyf));
+ BOOST_CHECK(!mask.includes(sp_yyg));
+}
+
+static void
+test_include_depth_1()
+{
+ roster_t roster;
+ setup(roster);
+
+ vector includes, excludes;
+ includes.push_back(utf8(string("x")));
+ includes.push_back(utf8(string("y")));
+
+ app_state app;
+ app.set_depth(1);
+ restriction mask(includes, excludes, roster, app);
+
+ BOOST_CHECK(!mask.empty());
+
+ // check restricted nodes
+ BOOST_CHECK( mask.includes(roster, nid_root));
+ BOOST_CHECK(!mask.includes(roster, nid_f));
+ BOOST_CHECK(!mask.includes(roster, nid_g));
+
+ BOOST_CHECK( mask.includes(roster, nid_x));
+ BOOST_CHECK( mask.includes(roster, nid_xf));
+ BOOST_CHECK( mask.includes(roster, nid_xg));
+ BOOST_CHECK( mask.includes(roster, nid_xx));
+ BOOST_CHECK(!mask.includes(roster, nid_xxf));
+ BOOST_CHECK(!mask.includes(roster, nid_xxg));
+ BOOST_CHECK( mask.includes(roster, nid_xy));
+ BOOST_CHECK(!mask.includes(roster, nid_xyf));
+ BOOST_CHECK(!mask.includes(roster, nid_xyg));
+
+ BOOST_CHECK( mask.includes(roster, nid_y));
+ BOOST_CHECK( mask.includes(roster, nid_yf));
+ BOOST_CHECK( mask.includes(roster, nid_yg));
+ BOOST_CHECK( mask.includes(roster, nid_yx));
+ BOOST_CHECK(!mask.includes(roster, nid_yxf));
+ BOOST_CHECK(!mask.includes(roster, nid_yxg));
+ BOOST_CHECK( mask.includes(roster, nid_yy));
+ BOOST_CHECK(!mask.includes(roster, nid_yyf));
+ BOOST_CHECK(!mask.includes(roster, nid_yyg));
+
+ // check restricted paths
+ BOOST_CHECK( mask.includes(sp_root));
+ BOOST_CHECK(!mask.includes(sp_f));
+ BOOST_CHECK(!mask.includes(sp_g));
+
+ BOOST_CHECK( mask.includes(sp_x));
+ BOOST_CHECK( mask.includes(sp_xf));
+ BOOST_CHECK( mask.includes(sp_xg));
+ BOOST_CHECK( mask.includes(sp_xx));
+ BOOST_CHECK(!mask.includes(sp_xxf));
+ BOOST_CHECK(!mask.includes(sp_xxg));
+ BOOST_CHECK( mask.includes(sp_xy));
+ BOOST_CHECK(!mask.includes(sp_xyf));
+ BOOST_CHECK(!mask.includes(sp_xyg));
+
+ BOOST_CHECK( mask.includes(sp_y));
+ BOOST_CHECK( mask.includes(sp_yf));
+ BOOST_CHECK( mask.includes(sp_yg));
+ BOOST_CHECK( mask.includes(sp_yx));
+ BOOST_CHECK(!mask.includes(sp_yxf));
+ BOOST_CHECK(!mask.includes(sp_yxg));
+ BOOST_CHECK( mask.includes(sp_yy));
+ BOOST_CHECK(!mask.includes(sp_yyf));
+ BOOST_CHECK(!mask.includes(sp_yyg));
+}
+
void
add_restrictions_tests(test_suite * suite)
{
@@ -901,6 +1041,8 @@
suite->add(BOOST_TEST_CASE(&test_exclude_include));
suite->add(BOOST_TEST_CASE(&test_invalid_paths));
suite->add(BOOST_TEST_CASE(&test_get_parent_paths));
+ suite->add(BOOST_TEST_CASE(&test_include_depth_0));
+ suite->add(BOOST_TEST_CASE(&test_include_depth_1));
}
#endif // BUILD_UNIT_TESTS
============================================================
--- restrictions.hh 8d68ee9d4981f22f01ecf499602fcbc7b6d4b6fe
+++ restrictions.hh 54a5faec54b44ad6dec5ac9aa7854467331181e6
@@ -60,26 +60,52 @@
class restriction
{
public:
- restriction() {}
+ restriction(app_state & a) : app(a) {}
restriction(vector const & includes,
vector const & excludes,
- roster_t const & roster);
+ roster_t const & roster,
+ app_state & a) :
+ app(a)
+ {
+ map_paths(includes, excludes);
+ map_nodes(roster);
+ validate();
+ }
restriction(vector const & includes,
vector const & excludes,
roster_t const & roster1,
- roster_t const & roster2);
+ roster_t const & roster2,
+ app_state & a) :
+ app(a)
+ {
+ map_paths(includes, excludes);
+ map_nodes(roster1);
+ map_nodes(roster2);
+ validate();
+ }
bool includes(roster_t const & roster, node_id nid) const;
bool includes(split_path const & sp) const;
- bool empty() { return node_map.empty(); }
+ bool empty() const { return included_paths.empty() && excluded_paths.empty(); }
+ restriction & operator=(restriction const & other)
+ {
+ included_paths = other.included_paths;
+ excluded_paths = other.excluded_paths;
+ known_paths = other.known_paths;
+ node_map = other.node_map;
+ path_map = other.path_map;
+ return *this;
+ }
+
private:
- bool default_result;
+ app_state & app;
+ path_set included_paths, excluded_paths, known_paths;
// we maintain maps by node_id and also by split_path, which is not
// particularly nice, but paths are required for checking unknown and ignored
@@ -87,6 +113,12 @@
map node_map;
map path_map;
+ void map_paths(vector const & includes,
+ vector const & excludes);
+
+ void map_nodes(roster_t const & roster);
+
+ void validate();
};
#endif // header guard
============================================================
--- roster.cc e5c5a7e458a6f7e8680f7f11052f3ffa9ae8714d
+++ roster.cc 91d762446711f8f866dc64341f0a24e14638a871
@@ -2184,7 +2184,7 @@
update_current_roster_from_filesystem(roster_t & ros,
app_state & app)
{
- restriction tmp;
+ restriction tmp(app);
update_current_roster_from_filesystem(ros, tmp, app);
}
============================================================
--- tests/t_automate_get_manifest_of.at d9c77a0178966dc2299c8fd72dffa6147a4bb494
+++ tests/t_automate_get_manifest_of.at edc1cee6363259bbb70e4c0f6b2fb0ec0b7f6f1b
@@ -12,8 +12,10 @@
content @<:@4cbd040533a2f43fc6691d773d510cda70f4126a@:>@
])
-AT_DATA(expected2, [dir ""
+AT_DATA(expected2, [format_version "1"
+dir ""
+
file "foo"
content @<:@9fd2be4badf713d640ae46bf4547d1549654dfe5@:>@
])
============================================================
--- tests/t_restrictions.at ca23ce3a30758abad47e9919544b743130bb66de
+++ tests/t_restrictions.at c3da9d248652641bdee32e01a7a91424035de387
@@ -42,22 +42,23 @@
AT_CHECK(MONOTONE add work/A/fileA, [], [ignore], [ignore])
AT_CHECK(MONOTONE add work/A/B/fileAB, [], [ignore], [ignore])
-# FIXME_RESTRICTIONS: replace --depth with ... recursive wildcards
-
+# FIXME_RESTRICTIONS: the old code allows for --depth=N with no paths
+# and adds the "." path so that depth is interpreted against the current
+# included directory. this seems bad. how does --depth interact with --exclude?
#AT_CHECK(MONOTONE ls known --depth=0, [], [stdout], [ignore])
#AT_CHECK(grep fileX stdout, [1], [ignore])
-#AT_CHECK(MONOTONE ls known --depth=0 . , [], [stdout], [ignore])
-#AT_CHECK(grep fileX stdout, [1], [ignore])
+AT_CHECK(MONOTONE ls known --depth=0 . , [], [stdout], [ignore])
+AT_CHECK(grep fileX stdout, [1], [ignore])
-#AT_CHECK(MONOTONE ls known --depth=1 . , [], [stdout], [ignore])
-#AT_CHECK(grep fileX stdout, [0], [ignore])
+AT_CHECK(MONOTONE ls known --depth=1 . , [], [stdout], [ignore])
+AT_CHECK(grep fileX stdout, [0], [ignore])
-#AT_CHECK(MONOTONE ls known --depth=0 work/A , [], [stdout], [ignore])
-#AT_CHECK(grep fileAB stdout, [1], [ignore])
+AT_CHECK(MONOTONE ls known --depth=0 work/A , [], [stdout], [ignore])
+AT_CHECK(grep fileAB stdout, [1], [ignore])
-#AT_CHECK(MONOTONE ls known --depth=1 work/A , [], [stdout], [ignore])
-#AT_CHECK(grep fileAB stdout, [0], [ignore])
+AT_CHECK(MONOTONE ls known --depth=1 work/A , [], [stdout], [ignore])
+AT_CHECK(grep fileAB stdout, [0], [ignore])
# test restriction of unknown, missing, ignored files
@@ -166,20 +167,18 @@
AT_CHECK(MONOTONE diff, [], [stdout], [ignore])
AT_CHECK(INCLUDED(X 1 2 3 4), [0], [ignore])
-# FIXME_RESTRICTIONS: replace --depth with ... recursive wildcards
+AT_CHECK(MONOTONE diff --depth=0 . , [], [stdout], [ignore])
+AT_CHECK(grep fileAB stdout, [1], [ignore])
-#AT_CHECK(MONOTONE diff --depth=0 . , [], [stdout], [ignore])
-#AT_CHECK(grep fileAB stdout, [1], [ignore])
+AT_CHECK(MONOTONE diff --depth=2 . , [], [stdout], [ignore])
+AT_CHECK(grep fileA stdout, [0], [ignore])
-#AT_CHECK(MONOTONE diff --depth=2 . , [], [stdout], [ignore])
-#AT_CHECK(grep fileA stdout, [0], [ignore])
+AT_CHECK(MONOTONE diff --context --depth=0 . , [], [stdout], [ignore])
+AT_CHECK(grep fileAB stdout, [1], [ignore])
-#AT_CHECK(MONOTONE diff --context --depth=0 . , [], [stdout], [ignore])
-#AT_CHECK(grep fileAB stdout, [1], [ignore])
+AT_CHECK(MONOTONE diff --context --depth=2 . , [], [stdout], [ignore])
+AT_CHECK(grep fileA stdout, [0], [ignore])
-#AT_CHECK(MONOTONE diff --context --depth=2 . , [], [stdout], [ignore])
-#AT_CHECK(grep fileA stdout, [0], [ignore])
-
# include both source and target of rename
AT_CHECK(MONOTONE diff work/fileX work/file1, [], [stdout], [ignore])