# # patch "roster.cc" # from [d0c6b289a91299d1c21be24141782718a94911ae] # to [18578e8344ff35a32638fe8aa09bfa81c0a99ba0] # # patch "roster.hh" # from [d99dc357b2b4f6bb7cfc24c256eb6415960a7886] # to [10fb6f11b2995a39f3c82441957196800171dd46] # # patch "roster_merge.cc" # from [1b0c5bb5568fee12d096cd5234721c331d90c27c] # to [ba7fc8b18d1a445624cade8edb1ddf98f5228e1e] # ======================================================================== --- roster.cc d0c6b289a91299d1c21be24141782718a94911ae +++ roster.cc 18578e8344ff35a32638fe8aa09bfa81c0a99ba0 @@ -95,7 +95,7 @@ std::string marking_str, indented_marking_str; dump(i->second, marking_str); prefix_lines_with(" ", marking_str, indented_marking_str); - oss << indented_marking_str; + oss << indented_marking_str << "\n"; } out = oss.str(); } @@ -676,44 +676,48 @@ path_component basename; dirname_basename(dst, dirname, basename); - node_t n = get_node(nid); + if (dirname.empty()) + // attaching the root node + attach_node(nid, the_null_node, basename); + else + attach_node(nid, get_node(dirname)->self, basename); +} +void +roster_t::attach_node(node_id nid, node_id parent, path_component name) +{ + node_t n = get_node(nid); + + I(!null_node(n->self)); // ensure the node is already detached (as best one can) I(null_node(n->parent)); I(null_name(n->name)); - I(!null_node(n->self)); // this iterator might point to old_locations.end(), because old_locations // only includes entries for renames, not new nodes std::map >::iterator i = old_locations.find(nid); - if (dirname.empty()) + if (null_node(parent) || null_name(name)) { - // attaching the root dir - // (we repeat the above checks to clarify dependencies, just in case - // someone changes the magic defaults and removes the above checks...) + I(null_node(parent) && null_name(name)); I(null_node(n->parent)); I(null_name(n->name)); - I(null_name(basename)); - I(!has_root()); root_dir = downcast_to_dir_t(n); I(i == old_locations.end() || i->second != make_pair(root_dir->parent, root_dir->name)); } else { - // L(F("attaching into dir '%s'\n") % file_path(dirname)); - dir_t parent = downcast_to_dir_t(get_node(dirname)); - parent->attach_child(basename, n); + dir_t parent_n = downcast_to_dir_t(get_node(parent)); + parent_n->attach_child(name, n); I(i == old_locations.end() || i->second != make_pair(n->parent, n->name)); } - + if (i != old_locations.end()) old_locations.erase(i); } - void roster_t::apply_delta(split_path const & pth, file_id const & old_id, ======================================================================== --- roster.hh d99dc357b2b4f6bb7cfc24c256eb6415960a7886 +++ roster.hh 10fb6f11b2995a39f3c82441957196800171dd46 @@ -183,6 +183,7 @@ node_id nid); void insert_node(node_t n); void attach_node(node_id n, split_path const & dst); + void attach_node(node_id n, node_id parent, path_component name); void apply_delta(split_path const & pth, file_id const & old_id, file_id const & new_new); ======================================================================== --- roster_merge.cc 1b0c5bb5568fee12d096cd5234721c331d90c27c +++ roster_merge.cc ba7fc8b18d1a445624cade8edb1ddf98f5228e1e @@ -118,9 +118,8 @@ n->attrs = old_n->attrs; if (is_file_t(n)) downcast_to_file_t(n)->content = downcast_to_file_t(old_n)->content; - dir_t const & p = downcast_to_dir_t(new_roster.get_node(old_n->parent)); // FIXME: this could hit a conflict! (orphan or rename-target) - p->attach_child(old_n->name, n); + new_roster.attach_node(n->self, old_n->parent, old_n->name); } } // end anonymous namespace @@ -136,6 +135,11 @@ { result.clear(); + MM(left_parent); + MM(left_marking); + MM(right_parent); + MM(right_marking); + MM(result.roster); // First handle lifecycles, by die-die-die merge -- our result will contain // everything that is alive in both parents, or alive in one and unborn in @@ -216,8 +220,8 @@ new_name, conflict)) { // FIXME: this could hit a conflict! (orphan or rename-target) - dir_t const & p = downcast_to_dir_t(result.roster.get_node(new_name.first)); - p->attach_child(new_name.second, new_n); + result.roster.attach_node(new_n->self, + new_name.first, new_name.second); } else {