# # patch "roster3.cc" # from [f0fb9e38f87eb501f7fe93ff34a60fd8aa9b3aa3] # to [876a0b829edfdc1ade90f093b151668537eca086] # # patch "roster3.hh" # from [e48dd575719a83620200e980d527640c38efa31d] # to [a297b3264ae4c6c133ddb15b29c3f8a7f016365e] # ======================================================================== --- roster3.cc f0fb9e38f87eb501f7fe93ff34a60fd8aa9b3aa3 +++ roster3.cc 876a0b829edfdc1ade90f093b151668537eca086 @@ -207,9 +207,7 @@ roster_t::clear_attr(split_path const & pth, attr_name const & name) { - node_id nid = lookup(pth); - node_t & n = node(nid); - safe_erase(n.attrs, name); + set_attr(pth, name, std::make_pair(false, attr_val())); } void @@ -217,9 +215,18 @@ attr_name const & name, attr_val const & val) { + set_attr(pth, name, std::make_pair(true, val)); +} + +void +roster_t::set_attr(split_path const & pth, + attr_name const & name, + std::pair const & val) +{ + I(val.first || val.second().empty()); node_id nid = lookup(pth); node_t & n = node(nid); - std::map::iterator i = n.attrs.find(name); + std::map >::iterator i = n.attrs.find(name); I(i != n.attrs.end()); I(i->second != val); i->second = val; ======================================================================== --- roster3.hh e48dd575719a83620200e980d527640c38efa31d +++ roster3.hh a297b3264ae4c6c133ddb15b29c3f8a7f016365e @@ -44,7 +44,10 @@ // this is null iff this is a root dir path_component name; file_id content; - std::map attrs; + // (true, "val") or (false, "") are both valid attr values (for proper + // merging, we have to widen the attr_value type to include a first-class + // "undefined" value). + std::map > attrs; }; typedef std::map dir_map; @@ -75,6 +78,9 @@ void set_attr(split_path const & pth, attr_name const & name, attr_val const & val); + void set_attr(split_path const & pth, + attr_name const & name, + std::pair const & val); std::map const & all_nodes() const { return nodes;