# # # patch "ChangeLog" # from [a80d1daa4cbca5505c6a5bd8385ce23460dc8d46] # to [2b8d1fbcd8c9aa847cac4eb99916f0ddb406efc6] # # patch "restrictions.cc" # from [9f39723316d3ce099ed5bcf9b49ca7f255ebff82] # to [8a45208f6fdad11caf24a17aa2e05b908135a357] # # patch "restrictions.hh" # from [d4f5430f74e4e2747729ddeeb8d77a79a3b98a2e] # to [de2f4620c0e8ca01eebfb919b0735e6e4182bb14] # ============================================================ --- ChangeLog a80d1daa4cbca5505c6a5bd8385ce23460dc8d46 +++ ChangeLog 2b8d1fbcd8c9aa847cac4eb99916f0ddb406efc6 @@ -1,3 +1,10 @@ +2006-03-31 Derek Scherger + + * restrictions.cc (get_nodes, merge_states): remove; + (add_paths, add_nodes, map_paths, map_nodes): simplify after above + cleanup and removal of implicit includes; + * restrictions.hh: remove stale comments + 2006-03-30 Derek Scherger * commands.cc (status, ls_changed, commit, diff, revert): call ============================================================ --- restrictions.cc 9f39723316d3ce099ed5bcf9b49ca7f255ebff82 +++ restrictions.cc 8a45208f6fdad11caf24a17aa2e05b908135a357 @@ -34,39 +34,6 @@ } static void -get_nodes(path_set const & paths, roster_t const & roster, - set & nodes, - path_set & known_paths) -{ - for (path_set::const_iterator i = paths.begin(); i != paths.end(); ++i) - { - if (roster.has_node(*i)) - { - known_paths.insert(*i); - node_id nid = roster.get_node(*i)->self; - nodes.insert(nid); - } - } -} - -static void -merge_states(path_state const & old_state, - path_state const & new_state, - path_state & merged_state, - split_path const & sp) -{ - if (old_state == new_state) - { - merged_state = old_state; - } - else - { - L(FL("path '%s' %d %d") % sp % old_state % new_state); - N(false, F("conflicting include/exclude on path '%s'") % sp); - } -} - -static void add_paths(map & path_map, path_set const & paths, path_state const state) @@ -75,41 +42,34 @@ { map::iterator p = path_map.find(*i); if (p != path_map.end()) - { - path_state merged; - merge_states(p->second, state, merged, *i); - p->second = merged; - } + N(p->second == state, + F("conflicting include/exclude on path '%s'") % *i); else - { - path_map.insert(make_pair(*i, state)); - } + path_map.insert(make_pair(*i, state)); } } static void add_nodes(map & node_map, roster_t const & roster, - set const & nodes, + path_set const & paths, + path_set & known, path_state const state) { - for (set::const_iterator i = nodes.begin(); i != nodes.end(); ++i) + for (path_set::const_iterator i = paths.begin(); i != paths.end(); ++i) { - I(roster.has_node(*i)); - - map::iterator n = node_map.find(*i); - if (n != node_map.end()) + if (roster.has_node(*i)) { - path_state merged; - split_path sp; - roster.get_name(*i, sp); - merge_states(n->second, state, merged, sp); - n->second = merged; + known.insert(*i); + node_id nid = roster.get_node(*i)->self; + + map::iterator n = node_map.find(nid); + if (n != node_map.end()) + N(n->second == state, + F("conflicting include/exclude on path '%s'") % *i); + else + node_map.insert(make_pair(nid, state)); } - else - { - node_map.insert(make_pair(*i, state)); - } } } @@ -126,25 +86,13 @@ add_paths(path_map, included_paths, included); add_paths(path_map, excluded_paths, excluded); - - L(FL("restriction paths: %d included; %d excluded") - % included_paths.size() - % excluded_paths.size()); } void restriction::map_nodes(roster_t const & roster) { - set included_nodes, excluded_nodes; - get_nodes(included_paths, roster, included_nodes, known_paths); - get_nodes(excluded_paths, roster, excluded_nodes, known_paths); - - add_nodes(node_map, roster, included_nodes, included); - add_nodes(node_map, roster, excluded_nodes, excluded); - - L(FL("restriction nodes: %d included; %d excluded") - % included_nodes.size() - % excluded_nodes.size()); + add_nodes(node_map, roster, included_paths, known_paths, included); + add_nodes(node_map, roster, excluded_paths, known_paths, excluded); } void ============================================================ --- restrictions.hh d4f5430f74e4e2747729ddeeb8d77a79a3b98a2e +++ restrictions.hh de2f4620c0e8ca01eebfb919b0735e6e4182bb14 @@ -50,13 +50,8 @@ // // revision A ... included ... revision X ... excluded ... revision B -// explicit in the sense that the path was explicitly given on the command line -// implicit in the sense that parent directories are included for explicit paths -// FIXME: should we really be doing implicit includes of parents? +enum path_state { included, excluded }; -// TODO: move these into the class below?!? -enum path_state { included, excluded }; - class restriction { public: