# # patch "roster.cc" # from [bf7d30ec9b558e778970c3e9f36c7f1d272cefdb] # to [a7be1586ac974d7ef805e0019a624b99160fc60c] # # patch "roster.hh" # from [a5d7f9771f5e6996ea8cb2774693df5e96f49c3d] # to [d99dc357b2b4f6bb7cfc24c256eb6415960a7886] # ======================================================================== --- roster.cc bf7d30ec9b558e778970c3e9f36c7f1d272cefdb +++ roster.cc a7be1586ac974d7ef805e0019a624b99160fc60c @@ -660,7 +660,7 @@ return nid; } void -roster_t::create_file_node(file_id const & content, node_id & nid) +roster_t::create_file_node(file_id const & content, node_id nid) { file_t f = file_t(new file_node()); f->self = nid; @@ -1730,7 +1730,7 @@ // returns true if merge was successful ('result' is valid), false otherwise // ('conflict_descriptor' is valid). -static template bool +template bool merge_scalar(T const & left, std::set const & left_marks, std::set const & left_uncommon_ancestors, @@ -1746,7 +1746,7 @@ return true; } bool left_wins = a_wins(right_marks, right_uncommon_ancestors); - bool right_wins = a_wins(left_wins, left_uncommon_ancestors); + bool right_wins = a_wins(left_marks, left_uncommon_ancestors); // two bools means 4 cases: // left_wins && right_wins // this is ambiguous clean merge, which is theoretically impossible. @@ -1777,27 +1777,25 @@ // conflicts encountered in that roster. Each conflict encountered in merging // the roster creates an entry in this list. -struct conflict -{ - node_id nid; - conflict(node_id nid) : nid(nid) {} -}; - // nodes with name conflicts are left detached in the resulting roster, with // null parent and name fields. // note that it is possible that the parent node on the left, the right, or // both, no longer exist in the merged roster. also note that it is possible // that on one or both sides, they do exist, but already have an entry with // the given name. -struct node_name_conflict : public conflict +struct node_name_conflict { + node_id nid; + node_name_conflict(node_id nid) : nid(nid) {} std::pair left, right; }; // files with content conflicts are left attached in resulting tree (unless // detached for some other reason), but with a null content hash. -struct file_content_conflict : public conflict +struct file_content_conflict { + node_id nid; + file_content_conflict(node_id nid) : nid(nid) {} file_id left, right; }; @@ -1807,8 +1805,10 @@ // roster insane (FIXME: we could put an invalid attr value in instead, like a // pair (false, "foo") (since the second value can only be non-null if the // first is 'true'). Should we do this?) -struct node_attr_conflict : public conflict +struct node_attr_conflict { + node_id nid; + node_attr_conflict(node_id nid) : nid(nid) {} attr_key key; std::pair left, right; }; @@ -1933,9 +1933,9 @@ { node_map::const_iterator left_i, right_i; parallel_state state = start; - while (parallel_iter_inc(state, - left_parent.all_nodes(), left_i, - right_parent.all_nodes(), right_i)) + while (parallel_iter_incr(state, + left_parent.all_nodes(), left_i, + right_parent.all_nodes(), right_i)) { switch (state) { @@ -1966,7 +1966,7 @@ // them in one at a time with *-merge. { node_map::const_iterator left_i, right_i; - node_map::const_iterator new_i = result.all_nodes().begin(); + node_map::const_iterator new_i = result.roster.all_nodes().begin(); marking_map::const_iterator left_mi = left_marking.begin(); marking_map::const_iterator right_mi = right_marking.begin(); parallel_state state = start; @@ -1999,7 +1999,7 @@ marking_t const & left_marking = left_mi->second; node_t const & right_n = right_i->second; marking_t const & right_marking = right_mi->second; - node_t & new_n = new_i->second; + node_t const & new_n = new_i->second; // merge name { std::pair new_name; @@ -2013,8 +2013,8 @@ new_name, conflict)) { // FIXME: this could hit a conflict! (orphan or rename-target) - dir_t const & p = downcast_to_dir_t(new_roster.get_node(new_name.parent)); - p->attach_child(new_n->name, new_n); + dir_t const & p = downcast_to_dir_t(result.roster.get_node(new_name.first)); + p->attach_child(new_name.second, new_n); } else { @@ -2077,7 +2077,8 @@ conflict)) { // successful merge - safe_insert(new_n->attrs, new_value); + safe_insert(new_n->attrs, + std::make_pair(left_ai->first, new_value)); } else { ======================================================================== --- roster.hh a5d7f9771f5e6996ea8cb2774693df5e96f49c3d +++ roster.hh d99dc357b2b4f6bb7cfc24c256eb6415960a7886 @@ -176,8 +176,11 @@ node_id detach_node(split_path const & src); void drop_detached_node(node_id n); node_id create_dir_node(node_id_source & nis); + void create_dir_node(node_id nid); node_id create_file_node(file_id const & content, node_id_source & nis); + void create_file_node(file_id const & content, + node_id nid); void insert_node(node_t n); void attach_node(node_id n, split_path const & dst); void apply_delta(split_path const & pth,