# # # patch "cmd_files.cc" # from [5c754bd725507628a28b4e526d6a7b5cc6c455e6] # to [5071ce2b623bb231f982e7c955afddb5f6919efd] # # patch "cmd_merging.cc" # from [8ffdc93fea885aef53e7208d9220a60bd17cee03] # to [7eaf99bb864a567857360e9aee6b1417ef8138aa] # # patch "cset.cc" # from [46e1d0a2704497281540fdb8eadf595557a8de1b] # to [476b18a5f46bb20ee22eba117535be9cc8b461be] # # patch "diff_patch.cc" # from [965f22af1e86ee242cb4a578e19d0f9bf3675852] # to [69c88a49ce6b06b466c6680d07badcb3f6833424] # # patch "packet.cc" # from [df0fa7f0af5b79f300c3bdc63940be1940af92e2] # to [b15e88ccbd9f8be27f1725224f2f76e91bb3665c] # # patch "paths.hh" # from [651d16d942ac079114409b40d3e2f21d2529b9ec] # to [60f51a22ea7531952d789c064b83490c3419eaef] # # patch "rcs_import.cc" # from [f77665e03e8ca727897dd9f35c644f09e0c460a0] # to [64e76f60aa1f60608af80c165240b3cc6567f62f] # # patch "revision.cc" # from [f840485a92a3fa9804903ea61eb45ed33344dcd5] # to [d82508920e55c80c57b00d22d651a495d3c0b491] # # patch "roster.cc" # from [787958094de79f2d120a47ada655397a241f3d23] # to [0146e6f4ad2059d0e53032e4c1bc90e3497c76a5] # # patch "roster_merge.cc" # from [275a8079ced7fd414802f69fb1d1d7f7cfdb23a5] # to [e4337633b15ec3ba3f9c9d47e72e955aa2a972f5] # # patch "work.cc" # from [8a409fe325bc29ba61477021c35f5d70c0a2eb11] # to [4c903c77d9fa1b12223c6586c92b3d87462dd730] # ============================================================ --- cmd_files.cc 5c754bd725507628a28b4e526d6a7b5cc6c455e6 +++ cmd_files.cc 5071ce2b623bb231f982e7c955afddb5f6919efd @@ -134,8 +134,6 @@ CMD(annotate, "annotate", "", CMD_REF(in throw usage(execid); file_path file = file_path_external(idx(args, 0)); - split_path sp; - file.split(sp); L(FL("annotate file '%s'") % file); @@ -178,9 +176,9 @@ CMD(annotate, "annotate", "", CMD_REF(in } // find the version of the file requested - N(roster.has_node(sp), + N(roster.has_node(file), F("no such file '%s' in revision '%s'") % file % rid); - node_t node = roster.get_node(sp); + node_t node = roster.get_node(file); N(is_file_t(node), F("'%s' in revision '%s' is not a file") % file % rid); @@ -266,18 +264,15 @@ dump_file(std::ostream & output, app_sta // Paths are interpreted as standard external ones when we're in a // workspace, but as project-rooted external ones otherwise. - file_path fp; - split_path sp; - fp = file_path_external(filename); - fp.split(sp); + file_path fp = file_path_external(filename); roster_t roster; marking_map marks; app.db.get_roster(rid, roster, marks); - N(roster.has_node(sp), + N(roster.has_node(fp), F("no file '%s' found in revision '%s'") % fp % rid); - node_t node = roster.get_node(sp); + node_t node = roster.get_node(fp); N((!null_node(node->self) && is_file_t(node)), F("no file '%s' found in revision '%s'") % fp % rid); ============================================================ --- cmd_merging.cc 8ffdc93fea885aef53e7208d9220a60bd17cee03 +++ cmd_merging.cc 7eaf99bb864a567857360e9aee6b1417ef8138aa @@ -544,9 +544,9 @@ CMD(merge_into_dir, "merge_into_dir", "" { file_path_external(idx(args,2)).split(sp); dirname_basename(sp, dirname, basename); - N(right_roster.has_node(dirname), + N(right_roster.has_node(file_path(dirname)), F("Path %s not found in destination tree.") % sp); - node_t parent = right_roster.get_node(dirname); + node_t parent = right_roster.get_node(file_path(dirname)); moved_root->parent = parent->self; moved_root->name = basename; marking_map::iterator ============================================================ --- cset.cc 46e1d0a2704497281540fdb8eadf595557a8de1b +++ cset.cc 476b18a5f46bb20ee22eba117535be9cc8b461be @@ -485,21 +485,17 @@ setup_roster(roster_t & r, file_id const r = roster_t(); { - split_path sp; - file_path().split(sp); - r.attach_node(r.create_dir_node(nis), sp); + r.attach_node(r.create_dir_node(nis), file_path_internal("")); } { - split_path sp; - file_path_internal("foo").split(sp); - r.attach_node(r.create_dir_node(nis), sp); - r.set_attr(sp, attr_key("attr_dir"), attr_value("value_dir")); + file_path fp = file_path_internal("foo"); + r.attach_node(r.create_dir_node(nis), fp); + r.set_attr(fp, attr_key("attr_dir"), attr_value("value_dir")); } { - split_path sp; - file_path_internal("foo/bar").split(sp); - r.attach_node(r.create_file_node(fid, nis), sp); - r.set_attr(sp, attr_key("attr_file"), attr_value("value_file")); + file_path fp = file_path_internal("foo/bar"); + r.attach_node(r.create_file_node(fid, nis), fp); + r.set_attr(fp, attr_key("attr_file"), attr_value("value_file")); } } @@ -772,13 +768,6 @@ UNIT_TEST(cset, basic_csets) file_path baz = file_path_internal("baz"); file_path quux = file_path_internal("quux"); - split_path roots, foos, foo_bars, bazs, quuxs; - root.split(roots); - foo.split(foos); - foo_bar.split(foo_bars); - baz.split(bazs); - quux.split(quuxs); - // some basic tests that should succeed { L(FL("TEST: cset add file")); @@ -786,8 +775,8 @@ UNIT_TEST(cset, basic_csets) cset cs; MM(cs); cs.files_added.insert(make_pair(baz, f2)); UNIT_TEST_CHECK_NOT_THROW(cs.apply_to(tree), logic_error); - UNIT_TEST_CHECK(is_file_t(r.get_node(bazs))); - UNIT_TEST_CHECK(downcast_to_file_t(r.get_node(bazs))->content == f2); + UNIT_TEST_CHECK(is_file_t(r.get_node(baz))); + UNIT_TEST_CHECK(downcast_to_file_t(r.get_node(baz))->content == f2); UNIT_TEST_CHECK(r.all_nodes().size() == 4); } @@ -797,7 +786,7 @@ UNIT_TEST(cset, basic_csets) cset cs; MM(cs); cs.dirs_added.insert(quux); UNIT_TEST_CHECK_NOT_THROW(cs.apply_to(tree), logic_error); - UNIT_TEST_CHECK(is_dir_t(r.get_node(quuxs))); + UNIT_TEST_CHECK(is_dir_t(r.get_node(quux))); UNIT_TEST_CHECK(r.all_nodes().size() == 4); } @@ -817,23 +806,22 @@ UNIT_TEST(cset, basic_csets) cset cs; MM(cs); cs.nodes_renamed.insert(make_pair(foo_bar, quux)); UNIT_TEST_CHECK_NOT_THROW(cs.apply_to(tree), logic_error); - UNIT_TEST_CHECK(is_file_t(r.get_node(quuxs))); - UNIT_TEST_CHECK(is_dir_t(r.get_node(foos))); - UNIT_TEST_CHECK(!r.has_node(foo_bars)); + UNIT_TEST_CHECK(is_file_t(r.get_node(quux))); + UNIT_TEST_CHECK(is_dir_t(r.get_node(foo))); + UNIT_TEST_CHECK(!r.has_node(foo_bar)); UNIT_TEST_CHECK(r.all_nodes().size() == 3); } { L(FL("TEST: cset rename dir")); - split_path quux_bar; - file_path_internal("quux/bar").split(quux_bar); + file_path quux_bar = file_path_internal("quux/bar"); setup_roster(r, f1, nis); cset cs; MM(cs); cs.nodes_renamed.insert(make_pair(foo, quux)); UNIT_TEST_CHECK_NOT_THROW(cs.apply_to(tree), logic_error); - UNIT_TEST_CHECK(is_dir_t(r.get_node(quuxs))); + UNIT_TEST_CHECK(is_dir_t(r.get_node(quux))); UNIT_TEST_CHECK(is_file_t(r.get_node(quux_bar))); - UNIT_TEST_CHECK(!r.has_node(foos)); + UNIT_TEST_CHECK(!r.has_node(foo)); UNIT_TEST_CHECK(r.all_nodes().size() == 3); } @@ -843,9 +831,9 @@ UNIT_TEST(cset, basic_csets) cset cs; MM(cs); cs.deltas_applied.insert(make_pair(foo_bar, make_pair(f1, f2))); UNIT_TEST_CHECK_NOT_THROW(cs.apply_to(tree), logic_error); - UNIT_TEST_CHECK(is_dir_t(r.get_node(foos))); - UNIT_TEST_CHECK(is_file_t(r.get_node(foo_bars))); - UNIT_TEST_CHECK(downcast_to_file_t(r.get_node(foo_bars))->content == f2); + UNIT_TEST_CHECK(is_dir_t(r.get_node(foo))); + UNIT_TEST_CHECK(is_file_t(r.get_node(foo_bar))); + UNIT_TEST_CHECK(downcast_to_file_t(r.get_node(foo_bar))->content == f2); UNIT_TEST_CHECK(r.all_nodes().size() == 3); } @@ -857,10 +845,10 @@ UNIT_TEST(cset, basic_csets) attr_value("klang"))); UNIT_TEST_CHECK_NOT_THROW(cs.apply_to(tree), logic_error); - full_attr_map_t attrs = (r.get_node(foo_bars))->attrs; + full_attr_map_t attrs = (r.get_node(foo_bar))->attrs; UNIT_TEST_CHECK(attrs[attr_key("ping")] == make_pair(true, attr_value("klang"))); - attrs = (r.get_node(foos))->attrs; + attrs = (r.get_node(foo))->attrs; UNIT_TEST_CHECK(attrs[attr_key("attr_dir")] == make_pair(true, attr_value("value_dir"))); UNIT_TEST_CHECK(r.all_nodes().size() == 3); @@ -874,7 +862,7 @@ UNIT_TEST(cset, basic_csets) attr_value("klang"))); cs.attrs_cleared.insert(make_pair(foo_bar, attr_key("attr_file"))); UNIT_TEST_CHECK_NOT_THROW(cs.apply_to(tree), logic_error); - UNIT_TEST_CHECK((r.get_node(foo_bars))->attrs[attr_key("attr_file")] + UNIT_TEST_CHECK((r.get_node(foo_bar))->attrs[attr_key("attr_file")] == make_pair(false, attr_value(""))); UNIT_TEST_CHECK(r.all_nodes().size() == 3); } @@ -894,16 +882,6 @@ UNIT_TEST(cset, basic_csets) file_path foo_subsub = file_path_internal("foo/subsub"); file_path foo_subsub_deep = file_path_internal("foo/subsub/deep"); - split_path quux_bars; quux_bar.split(quux_bars); - split_path foo_bars; foo_bar.split(foo_bars); - split_path quux_subs; quux_sub.split(quux_subs); - split_path foo_subs; foo_sub.split(foo_subs); - split_path foo_sub_things; foo_sub_thing.split(foo_sub_things); - split_path quux_sub_things; quux_sub_thing.split(quux_sub_things); - split_path foo_sub_deeps; foo_sub_deep.split(foo_sub_deeps); - split_path foo_subsubs; foo_subsub.split(foo_subsubs); - split_path foo_subsub_deeps; foo_subsub_deep.split(foo_subsub_deeps); - { // build a tree cset cs; MM(cs); cs.dirs_added.insert(quux); @@ -925,16 +903,16 @@ UNIT_TEST(cset, basic_csets) UNIT_TEST_CHECK(r.all_nodes().size() == 8); // /foo/bar -> /quux/bar - UNIT_TEST_CHECK(is_file_t(r.get_node(quux_bars))); - UNIT_TEST_CHECK(!(r.has_node(foo_bars))); + UNIT_TEST_CHECK(is_file_t(r.get_node(quux_bar))); + UNIT_TEST_CHECK(!(r.has_node(foo_bar))); // /foo/sub/deep -> /foo/subsub/deep - UNIT_TEST_CHECK(is_file_t(r.get_node(foo_subsub_deeps))); - UNIT_TEST_CHECK(!(r.has_node(foo_sub_deeps))); + UNIT_TEST_CHECK(is_file_t(r.get_node(foo_subsub_deep))); + UNIT_TEST_CHECK(!(r.has_node(foo_sub_deep))); // /quux/sub -> /foo/sub - UNIT_TEST_CHECK(is_dir_t(r.get_node(foo_subs))); - UNIT_TEST_CHECK(!(r.has_node(quux_subs))); + UNIT_TEST_CHECK(is_dir_t(r.get_node(foo_sub))); + UNIT_TEST_CHECK(!(r.has_node(quux_sub))); // /quux/sub/thing -> /foo/sub/thing - UNIT_TEST_CHECK(is_file_t(r.get_node(foo_sub_things))); + UNIT_TEST_CHECK(is_file_t(r.get_node(foo_sub_thing))); } { @@ -945,7 +923,7 @@ UNIT_TEST(cset, basic_csets) cs.nodes_deleted.insert(foo); UNIT_TEST_CHECK_NOT_THROW(cs.apply_to(tree), logic_error); UNIT_TEST_CHECK(r.all_nodes().size() == 2); - UNIT_TEST_CHECK(is_file_t(r.get_node(foos))); + UNIT_TEST_CHECK(is_file_t(r.get_node(foo))); } } @@ -1129,7 +1107,6 @@ UNIT_TEST(cset, root_dir) file_id f1(string("0000000000000000000000000000000000000001")); file_path root, baz = file_path_internal("baz"); - split_path roots; root.split(roots); { L(FL("TEST: can rename root")); @@ -1145,7 +1122,7 @@ UNIT_TEST(cset, root_dir) L(FL("TEST: can delete root (but it makes us insane)")); // for this test, make sure root has no contents r = roster_t(); - r.attach_node(r.create_dir_node(nis), roots); + r.attach_node(r.create_dir_node(nis), root); cset cs; MM(cs); cs.nodes_deleted.insert(root); cs.apply_to(tree); @@ -1154,7 +1131,7 @@ UNIT_TEST(cset, root_dir) { L(FL("TEST: can delete and replace root")); r = roster_t(); - r.attach_node(r.create_dir_node(nis), roots); + r.attach_node(r.create_dir_node(nis), root); cset cs; MM(cs); cs.nodes_deleted.insert(root); cs.dirs_added.insert(root); ============================================================ --- diff_patch.cc 965f22af1e86ee242cb4a578e19d0f9bf3675852 +++ diff_patch.cc 69c88a49ce6b06b466c6680d07badcb3f6833424 @@ -651,9 +651,7 @@ content_merger::get_file_encoding(file_p roster_t const & ros) { attr_value v; - split_path sp; - path.split(sp); - if (ros.get_attr(sp, attr_key(constants::encoding_attribute), v)) + if (ros.get_attr(path, attr_key(constants::encoding_attribute), v)) return v(); return constants::default_encoding; } @@ -663,9 +661,7 @@ content_merger::attribute_manual_merge(f roster_t const & ros) { attr_value v; - split_path sp; - path.split(sp); - if (ros.get_attr(sp, attr_key(constants::manual_merge_attribute), v) + if (ros.get_attr(path, attr_key(constants::manual_merge_attribute), v) && v() == "true") return true; return false; // default: enable auto merge ============================================================ --- packet.cc df0fa7f0af5b79f300c3bdc63940be1940af92e2 +++ packet.cc b15e88ccbd9f8be27f1725224f2f76e91bb3665c @@ -311,10 +311,8 @@ UNIT_TEST(packet, roundabout) // a rdata packet revision_t rev; rev.new_manifest = manifest_id(string("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")); - split_path sp; - file_path_internal("").split(sp); shared_ptr cs(new cset); - cs->dirs_added.insert(sp); + cs->dirs_added.insert(file_path_internal("")); rev.edges.insert(make_pair(revision_id(string("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")), cs)); revision_data rdat; ============================================================ --- paths.hh 651d16d942ac079114409b40d3e2f21d2529b9ec +++ paths.hh 60f51a22ea7531952d789c064b83490c3419eaef @@ -151,7 +151,7 @@ public: public: file_path() {} // join a file_path out of pieces - file_path(split_path const & sp); + explicit file_path(split_path const & sp); // this currently doesn't do any normalization or anything. file_path operator /(std::string const & to_append) const; ============================================================ --- rcs_import.cc f77665e03e8ca727897dd9f35c644f09e0c460a0 +++ rcs_import.cc 64e76f60aa1f60608af80c165240b3cc6567f62f @@ -1391,7 +1391,7 @@ cluster_consumer::add_missing_parents(sp if (created_dirs.find(tmp) == created_dirs.end()) { safe_insert(created_dirs, tmp); - safe_insert(cs.dirs_added, tmp); + safe_insert(cs.dirs_added, file_path(tmp)); } tmp.pop_back(); } @@ -1435,7 +1435,7 @@ cluster_consumer::build_cset(cvs_cluster if (e != live_files.end()) { L(FL("deleting entry state '%s' on '%s'") % fid % pth); - safe_insert(cs.nodes_deleted, sp); + safe_insert(cs.nodes_deleted, pth); live_files.erase(i->first); } } ============================================================ --- revision.cc f840485a92a3fa9804903ea61eb45ed33344dcd5 +++ revision.cc d82508920e55c80c57b00d22d651a495d3c0b491 @@ -1211,42 +1211,40 @@ insert_into_roster(roster_t & child_rost file_path const & pth, file_id const & fid) { - split_path sp, dirname; - path_component basename; - pth.split(sp); + if (child_roster.has_node(pth)) + { + node_t n = child_roster.get_node(pth); + E(is_file_t(n), + F("Path %s cannot be added, as there is a directory in the way") % pth); + file_t f = downcast_to_file_t(n); + E(f->content == fid, + F("Path %s added twice with differing content") % pth); + return; + } - E(!child_roster.has_node(sp), - F("Path %s added to child roster multiple times") % pth); - - dirname_basename(sp, dirname, basename); - { + split_path sp, dirname; + path_component basename; + pth.split(sp); + dirname_basename(sp, dirname, basename); split_path tmp_pth; for (split_path::const_iterator i = dirname.begin(); i != dirname.end(); ++i) { tmp_pth.push_back(*i); - if (child_roster.has_node(tmp_pth)) + if (child_roster.has_node(file_path(tmp_pth))) { - E(is_dir_t(child_roster.get_node(tmp_pth)), - F("Directory for path %s cannot be added, as there is a file in the way") % pth); + E(is_dir_t(child_roster.get_node(file_path(tmp_pth))), + F("Directory %s for path %s cannot be added, " + "as there is a file in the way") % file_path(tmp_pth) % pth); } else - child_roster.attach_node(child_roster.create_dir_node(nis), tmp_pth); + child_roster.attach_node(child_roster.create_dir_node(nis), + file_path(tmp_pth)); } } - if (child_roster.has_node(sp)) - { - node_t n = child_roster.get_node(sp); - E(is_file_t(n), - F("Path %s cannot be added, as there is a directory in the way") % sp); - file_t f = downcast_to_file_t(n); - E(f->content == fid, - F("Path %s added twice with differing content") % sp); - } - else - child_roster.attach_node(child_roster.create_file_node(fid, nis), sp); + child_roster.attach_node(child_roster.create_file_node(fid, nis), pth); } void @@ -1330,10 +1328,10 @@ anc_graph::fixup_node_identities(parent_ // See if we can match this node against a child. if ((!child_roster.has_node(n)) - && child_roster.has_node(sp)) + && child_roster.has_node(file_path(sp))) { node_t pn = parent_roster->get_node(n); - node_t cn = child_roster.get_node(sp); + node_t cn = child_roster.get_node(file_path(sp)); if (is_file_t(pn) == is_file_t(cn)) { child_roster.replace_node_id(cn->self, n); @@ -1480,11 +1478,8 @@ anc_graph::construct_revisions_from_ance temp_node_id_source nis; // all rosters shall have a root node. - { - split_path root_pth; - file_path().split(root_pth); - child_roster.attach_node(child_roster.create_dir_node(nis), root_pth); - } + child_roster.attach_node(child_roster.create_dir_node(nis), + file_path_internal("")); for (legacy::manifest_map::const_iterator i = old_child_man.begin(); i != old_child_man.end(); ++i) @@ -1512,9 +1507,7 @@ anc_graph::construct_revisions_from_ance for (legacy::dot_mt_attrs_map::const_iterator j = attrs.begin(); j != attrs.end(); ++j) { - split_path sp; - j->first.split(sp); - if (child_roster.has_node(sp)) + if (child_roster.has_node(j->first)) { map const & fattrs = j->second; @@ -1528,7 +1521,7 @@ anc_graph::construct_revisions_from_ance // ignore it } else if (key == "execute" || key == "manual_merge") - child_roster.set_attr(sp, + child_roster.set_attr(j->first, attr_key("mtn:" + key), attr_value(k->second)); else @@ -1536,7 +1529,7 @@ anc_graph::construct_revisions_from_ance "please contact %s so we can work out the right way to migrate this\n" "(if you just want it to go away, see the switch --drop-attr, but\n" "seriously, if you'd like to keep it, we're happy to figure out how)") - % key % file_path(sp) % PACKAGE_BUGREPORT); + % key % j->first % PACKAGE_BUGREPORT); } } } ============================================================ --- roster.cc 787958094de79f2d120a47ada655397a241f3d23 +++ roster.cc 0146e6f4ad2059d0e53032e4c1bc90e3497c76a5 @@ -721,7 +721,7 @@ roster_t::detach_node(file_path const & return root_id; } - dir_t parent = downcast_to_dir_t(get_node(dirname)); + dir_t parent = downcast_to_dir_t(get_node(file_path(dirname))); node_id nid = parent->detach_child(basename)->self; safe_insert(old_locations, make_pair(nid, make_pair(parent->self, basename))); @@ -825,7 +825,7 @@ roster_t::attach_node(node_id nid, file_ // attaching the root node attach_node(nid, the_null_node, basename); else - attach_node(nid, get_node(dirname)->self, basename); + attach_node(nid, get_node(file_path(dirname))->self, basename); } void @@ -2311,7 +2311,7 @@ editable_roster_for_check::attach_node(n path_component basename; dirname_basename(sd, dirname, basename); - if (!dirname.empty() && !r.has_node(dirname)) + if (!dirname.empty() && !r.has_node(file_path(dirname))) { W(F("restriction excludes addition of '%s' but includes addition of '%s'") % dirname % dst); @@ -3077,12 +3077,13 @@ void perform_random_action(roster_t & r, if (rng.flip()) { // L(FL("adding dir '%s'") % file_path(pth)); - safe_insert(c.dirs_added, pth); + safe_insert(c.dirs_added, file_path(pth)); } else { // L(FL("adding file '%s'") % file_path(pth)); - safe_insert(c.files_added, make_pair(pth, new_ident(rng))); + safe_insert(c.files_added, make_pair(file_path(pth), + new_ident(rng))); } break; @@ -3092,8 +3093,9 @@ void perform_random_action(roster_t & r, // L(FL("altering content of file '%s'") % file_path(pth)); safe_insert(c.deltas_applied, make_pair - (pth, make_pair(downcast_to_file_t(n)->content, - new_ident(rng)))); + (file_path(pth), + make_pair(downcast_to_file_t(n)->content, + new_ident(rng)))); } break; @@ -3128,7 +3130,8 @@ void perform_random_action(roster_t & r, { // L(FL("renaming '%s' -> '%s") // % file_path(pth) % file_path(pth2)); - safe_insert(c.nodes_renamed, make_pair(pth, pth2)); + safe_insert(c.nodes_renamed, make_pair(file_path(pth), + file_path(pth2))); } } break; @@ -3139,7 +3142,7 @@ void perform_random_action(roster_t & r, && r.all_nodes().size() > 1) // do not delete the root { // L(FL("deleting '%s'") % file_path(pth)); - safe_insert(c.nodes_deleted, pth); + safe_insert(c.nodes_deleted, file_path(pth)); } break; @@ -3152,13 +3155,14 @@ void perform_random_action(roster_t & r, if (rng.flip()) { // L(FL("clearing attr on '%s'") % file_path(pth)); - safe_insert(c.attrs_cleared, make_pair(pth, k)); + safe_insert(c.attrs_cleared, make_pair(file_path(pth), k)); } else { // L(FL("changing attr on '%s'\n") % file_path(pth)); safe_insert(c.attrs_set, - make_pair(make_pair(pth, k), new_word(rng))); + make_pair(make_pair(file_path(pth), k), + new_word(rng))); } } else @@ -3166,14 +3170,16 @@ void perform_random_action(roster_t & r, // L(FL("setting previously set attr on '%s'") // % file_path(pth)); safe_insert(c.attrs_set, - make_pair(make_pair(pth, k), new_word(rng))); + make_pair(make_pair(file_path(pth), k), + new_word(rng))); } } else { // L(FL("setting attr on '%s'") % file_path(pth)); safe_insert(c.attrs_set, - make_pair(make_pair(pth, new_word(rng)), new_word(rng))); + make_pair(make_pair(file_path(pth), new_word(rng)), + new_word(rng))); } break; } @@ -3211,10 +3217,8 @@ UNIT_TEST(roster, random_actions) { // give all the rosters a root - split_path root; cset c; - root.push_back(the_null_component); - c.dirs_added.insert(root); + c.dirs_added.insert(file_path()); apply_cset_and_do_testing(r, c, nis); } @@ -3266,36 +3270,36 @@ check_sane_roster_do_tests(int to_run, i MAYBE(UNIT_TEST_CHECK_THROW(r.check_sane(false), logic_error)); MAYBE(UNIT_TEST_CHECK_THROW(r.check_sane(true), logic_error)); - split_path sp_, sp_foo, sp_foo_bar, sp_foo_baz; - file_path().split(sp_); - file_path_internal("foo").split(sp_foo); - file_path_internal("foo/bar").split(sp_foo_bar); - file_path_internal("foo/baz").split(sp_foo_baz); + file_path fp_; + file_path fp_foo = file_path_internal("foo"); + file_path fp_foo_bar = file_path_internal("foo/bar"); + file_path fp_foo_baz = file_path_internal("foo/baz"); + node_id nid_f = r.create_file_node(file_id(string("0000000000000000000000000000000000000000")), nis); // root must be a directory, not a file - MAYBE(UNIT_TEST_CHECK_THROW(r.attach_node(nid_f, sp_), logic_error)); + MAYBE(UNIT_TEST_CHECK_THROW(r.attach_node(nid_f, fp_), logic_error)); node_id root_dir = r.create_dir_node(nis); - r.attach_node(root_dir, sp_); + r.attach_node(root_dir, fp_); // has a root dir, but a detached file MAYBE(UNIT_TEST_CHECK_THROW(r.check_sane(false), logic_error)); MAYBE(UNIT_TEST_CHECK_THROW(r.check_sane(true), logic_error)); - r.attach_node(nid_f, sp_foo); + r.attach_node(nid_f, fp_foo); // now should be sane UNIT_TEST_CHECK_NOT_THROW(r.check_sane(false), logic_error); UNIT_TEST_CHECK_NOT_THROW(r.check_sane(true), logic_error); node_id nid_d = r.create_dir_node(nis); // if "foo" exists, can't attach another node at "foo" - MAYBE(UNIT_TEST_CHECK_THROW(r.attach_node(nid_d, sp_foo), logic_error)); + MAYBE(UNIT_TEST_CHECK_THROW(r.attach_node(nid_d, fp_foo), logic_error)); // if "foo" is a file, can't attach a node at "foo/bar" - MAYBE(UNIT_TEST_CHECK_THROW(r.attach_node(nid_d, sp_foo_bar), logic_error)); + MAYBE(UNIT_TEST_CHECK_THROW(r.attach_node(nid_d, fp_foo_bar), logic_error)); - UNIT_TEST_CHECK(r.detach_node(sp_foo) == nid_f); - r.attach_node(nid_d, sp_foo); - r.attach_node(nid_f, sp_foo_bar); + UNIT_TEST_CHECK(r.detach_node(fp_foo) == nid_f); + r.attach_node(nid_d, fp_foo); + r.attach_node(nid_f, fp_foo_bar); UNIT_TEST_CHECK_NOT_THROW(r.check_sane(false), logic_error); UNIT_TEST_CHECK_NOT_THROW(r.check_sane(true), logic_error); @@ -3304,7 +3308,7 @@ check_sane_roster_do_tests(int to_run, i // has a detached node MAYBE(UNIT_TEST_CHECK_THROW(r.check_sane(false), logic_error)); MAYBE(UNIT_TEST_CHECK_THROW(r.check_sane(true), logic_error)); - r.attach_node(nid_tmp, sp_foo_baz); + r.attach_node(nid_tmp, fp_foo_baz); // now has no detached nodes, but one temp node MAYBE(UNIT_TEST_CHECK_THROW(r.check_sane(false), logic_error)); UNIT_TEST_CHECK_NOT_THROW(r.check_sane(true), logic_error); @@ -3328,14 +3332,12 @@ UNIT_TEST(roster, check_sane_roster_loop { testing_node_id_source nis; roster_t r; MM(r); - split_path root, foo_bar; - file_path().split(root); - file_path_internal("foo/bar").split(foo_bar); + file_path root; r.attach_node(r.create_dir_node(nis), root); node_id nid_foo = r.create_dir_node(nis); node_id nid_bar = r.create_dir_node(nis); - r.attach_node(nid_foo, nid_bar, foo_bar[1]); - r.attach_node(nid_bar, nid_foo, foo_bar[2]); + r.attach_node(nid_foo, nid_bar, path_component("foo")); + r.attach_node(nid_bar, nid_foo, path_component("bar")); UNIT_TEST_CHECK_THROW(r.check_sane(true), logic_error); } @@ -3343,14 +3345,13 @@ UNIT_TEST(roster, check_sane_roster_scre { testing_node_id_source nis; roster_t r; MM(r); - split_path root, foo; - file_path().split(root); - file_path_internal("foo").split(foo); + file_path root; r.attach_node(r.create_dir_node(nis), root); roster_t other; MM(other); node_id other_nid = other.create_dir_node(nis); dir_t root_n = downcast_to_dir_t(r.get_node(root)); - root_n->children.insert(make_pair(*(foo.end()-1), other.get_node(other_nid))); + root_n->children.insert(make_pair(path_component("foo"), + other.get_node(other_nid))); UNIT_TEST_CHECK_THROW(r.check_sane(), logic_error); // well, but that one was easy, actually, because a dir traversal will hit // more nodes than actually exist... so let's make it harder, by making sure @@ -3360,7 +3361,7 @@ UNIT_TEST(roster, check_sane_roster_scre // and even harder, by making that node superficially valid too dir_t distractor_n = downcast_to_dir_t(r.get_node(distractor_nid)); distractor_n->parent = distractor_nid; - distractor_n->name = *(foo.end()-1); + distractor_n->name = path_component("foo"); distractor_n->children.insert(make_pair(distractor_n->name, distractor_n)); UNIT_TEST_CHECK_THROW(r.check_sane(), logic_error); } @@ -3369,8 +3370,7 @@ UNIT_TEST(roster, bad_attr) { testing_node_id_source nis; roster_t r; MM(r); - split_path root; - file_path().split(root); + file_path root; r.attach_node(r.create_dir_node(nis), root); UNIT_TEST_CHECK_THROW(r.set_attr(root, attr_key("test_key1"), make_pair(false, attr_value("invalid"))), @@ -3394,7 +3394,8 @@ UNIT_TEST(roster, bad_attr) // purpose of this section is to systematically and exhaustively test every // possible case. // -// Our underlying merger, *-merge, works on scalars, case-by-case. The cases are: +// Our underlying merger, *-merge, works on scalars, case-by-case. +// The cases are: // 0 parent: // a* // 1 parent: @@ -3487,14 +3488,6 @@ namespace revision_id right_rid(string("2222222222222222222222222222222222222222")); revision_id new_rid(string("4444444444444444444444444444444444444444")); - split_path - split(string const & s) - { - split_path sp; - file_path_internal(s).split(sp); - return sp; - } - //////////////// // These classes encapsulate information about all the different scalars // that *-merge applies to. @@ -3534,7 +3527,7 @@ namespace void setup(roster_t & roster, marking_map & markings) { roster.create_dir_node(root_nid); - roster.attach_node(root_nid, split("")); + roster.attach_node(root_nid, file_path_internal("")); marking_t marking; marking.birth_revision = old_rid; marking.parent_name.insert(old_rid); @@ -3622,7 +3615,7 @@ namespace file_maker::make_file(scalar_origin_rid, obj_under_test_nid, safe_get(values, val), roster, markings); - roster.attach_node(obj_under_test_nid, split("foo")); + roster.attach_node(obj_under_test_nid, file_path_internal("foo")); markings[obj_under_test_nid].file_content = this_scalar_mark; } roster.check_sane_against(markings); @@ -3634,13 +3627,13 @@ namespace { virtual string my_type() const { return "X_basename_scalar"; } - map values; + map values; X_basename_scalar(node_id_source & nis) : a_scalar(nis) { - safe_insert(values, make_pair(scalar_a, split("a"))); - safe_insert(values, make_pair(scalar_b, split("b"))); - safe_insert(values, make_pair(scalar_c, split("c"))); + safe_insert(values, make_pair(scalar_a, file_path_internal("a"))); + safe_insert(values, make_pair(scalar_b, file_path_internal("b"))); + safe_insert(values, make_pair(scalar_c, file_path_internal("c"))); } virtual void set(revision_id const & scalar_origin_rid, scalar_val val, @@ -3663,24 +3656,24 @@ namespace { virtual string my_type() const { return "X_parent_scalar"; } - map values; + map values; node_id const a_nid, b_nid, c_nid; X_parent_scalar(node_id_source & nis) : a_scalar(nis), a_nid(nis.next()), b_nid(nis.next()), c_nid(nis.next()) { - safe_insert(values, make_pair(scalar_a, split("dir_a/foo"))); - safe_insert(values, make_pair(scalar_b, split("dir_b/foo"))); - safe_insert(values, make_pair(scalar_c, split("dir_c/foo"))); + safe_insert(values, make_pair(scalar_a, file_path_internal("dir_a/foo"))); + safe_insert(values, make_pair(scalar_b, file_path_internal("dir_b/foo"))); + safe_insert(values, make_pair(scalar_c, file_path_internal("dir_c/foo"))); } void setup_dirs(roster_t & roster, marking_map & markings) { roster.create_dir_node(a_nid); - roster.attach_node(a_nid, split("dir_a")); + roster.attach_node(a_nid, file_path_internal("dir_a")); roster.create_dir_node(b_nid); - roster.attach_node(b_nid, split("dir_b")); + roster.attach_node(b_nid, file_path_internal("dir_b")); roster.create_dir_node(c_nid); - roster.attach_node(c_nid, split("dir_c")); + roster.attach_node(c_nid, file_path_internal("dir_c")); marking_t marking; marking.birth_revision = old_rid; marking.parent_name.insert(old_rid); @@ -3729,7 +3722,7 @@ namespace // _not_ scalar_origin_rid, because our object exists everywhere, regardless of // when the attr shows up T::make_obj(old_rid, obj_under_test_nid, roster, markings); - roster.attach_node(obj_under_test_nid, split("foo")); + roster.attach_node(obj_under_test_nid, file_path_internal("foo")); if (val != scalar_none) { safe_insert(roster.get_node(obj_under_test_nid)->attrs, @@ -3764,7 +3757,7 @@ namespace if (val != scalar_none) { T::make_obj(scalar_origin_rid, obj_under_test_nid, roster, markings); - roster.attach_node(obj_under_test_nid, split("foo")); + roster.attach_node(obj_under_test_nid, file_path_internal("foo")); safe_insert(roster.get_node(obj_under_test_nid)->attrs, make_pair(attr_key("test_key"), safe_get(values, val))); markings[obj_under_test_nid].attrs[attr_key("test_key")] = this_scalar_mark; @@ -4284,7 +4277,7 @@ namespace if (val != scalar_none) { T::make_obj(scalar_origin_rid, obj_under_test_nid, roster, markings); - roster.attach_node(obj_under_test_nid, split("foo")); + roster.attach_node(obj_under_test_nid, file_path_internal("foo")); } if (val != scalar_none && val != scalar_none_2) { @@ -4357,17 +4350,18 @@ UNIT_TEST(roster, die_die_die_merge) testing_node_id_source nis; // left roster is empty except for the root - left_roster.attach_node(left_roster.create_dir_node(nis), split("")); + left_roster.attach_node(left_roster.create_dir_node(nis), file_path()); marking_t an_old_marking; an_old_marking.birth_revision = old_rid; an_old_marking.parent_name = singleton(old_rid); - safe_insert(left_markings, make_pair(left_roster.get_node(split(""))->self, + safe_insert(left_markings, make_pair(left_roster.root()->self, an_old_marking)); // right roster is identical, except for a dir created in the old rev right_roster = left_roster; right_markings = left_markings; - right_roster.attach_node(right_roster.create_dir_node(nis), split("foo")); - safe_insert(right_markings, make_pair(right_roster.get_node(split("foo"))->self, + right_roster.attach_node(right_roster.create_dir_node(nis), + file_path_internal("foo")); + safe_insert(right_markings, make_pair(right_roster.get_node(file_path_internal("foo"))->self, an_old_marking)); left_roster.check_sane_against(left_markings); @@ -4375,7 +4369,7 @@ UNIT_TEST(roster, die_die_die_merge) cset left_cs; MM(left_cs); // we add the node - left_cs.dirs_added.insert(split("foo")); + left_cs.dirs_added.insert(file_path_internal("foo")); // we do nothing cset right_cs; MM(right_cs); @@ -4413,11 +4407,11 @@ UNIT_TEST(roster, same_nid_diff_type) roster_t dir_roster; MM(dir_roster); marking_map dir_markings; MM(dir_markings); - dir_roster.attach_node(dir_roster.create_dir_node(nis), split("")); + dir_roster.attach_node(dir_roster.create_dir_node(nis), file_path()); marking_t marking; marking.birth_revision = old_rid; marking.parent_name = singleton(old_rid); - safe_insert(dir_markings, make_pair(dir_roster.get_node(split(""))->self, + safe_insert(dir_markings, make_pair(dir_roster.root()->self, marking)); roster_t file_roster; MM(file_roster); @@ -4428,11 +4422,11 @@ UNIT_TEST(roster, same_nid_diff_type) // okay, they both have the root dir node_id nid = nis.next(); dir_roster.create_dir_node(nid); - dir_roster.attach_node(nid, split("foo")); + dir_roster.attach_node(nid, file_path_internal("foo")); safe_insert(dir_markings, make_pair(nid, marking)); file_roster.create_file_node(new_ident(rng), nid); - file_roster.attach_node(nid, split("foo")); + file_roster.attach_node(nid, file_path_internal("foo")); marking.file_content = singleton(old_rid); safe_insert(file_markings, make_pair(nid, marking)); @@ -4473,15 +4467,15 @@ UNIT_TEST(roster, write_roster) marking_map mm; MM(mm); testing_node_id_source nis; - split_path root, foo, xx, fo, foo_bar, foo_ang, foo_zoo; - file_path().split(root); - file_path_internal("foo").split(foo); - file_path_internal("foo/ang").split(foo_ang); - file_path_internal("foo/bar").split(foo_bar); - file_path_internal("foo/zoo").split(foo_zoo); - file_path_internal("fo").split(fo); - file_path_internal("xx").split(xx); + file_path root; + file_path foo = file_path_internal("foo"); + file_path foo_ang = file_path_internal("foo/ang"); + file_path foo_bar = file_path_internal("foo/bar"); + file_path foo_zoo = file_path_internal("foo/zoo"); + file_path fo = file_path_internal("fo"); + file_path xx = file_path_internal("xx"); + file_id f1(string("1111111111111111111111111111111111111111")); revision_id rid(string("1234123412341234123412341234123412341234")); node_id nid; @@ -4620,10 +4614,9 @@ UNIT_TEST(roster, check_sane_against) UNIT_TEST(roster, check_sane_against) { testing_node_id_source nis; - split_path root, foo, bar; - file_path().split(root); - file_path_internal("foo").split(foo); - file_path_internal("bar").split(bar); + file_path root; + file_path foo = file_path_internal("foo"); + file_path bar = file_path_internal("bar"); file_id f1(string("1111111111111111111111111111111111111111")); revision_id rid(string("1234123412341234123412341234123412341234")); @@ -4825,14 +4818,12 @@ create_random_unification_task(roster_t if (!left.has_root()) { I(!right.has_root()); - split_path root; - root.push_back(the_null_component); node_id left_nid = left_erm.create_dir_node(); - left_erm.attach_node(left_nid, root); + left_erm.attach_node(left_nid, file_path()); node_id right_nid = right_erm.create_dir_node(); - right_erm.attach_node(right_nid, root); + right_erm.attach_node(right_nid, file_path()); } // Now throw in a bunch of others @@ -4878,8 +4869,8 @@ create_random_unification_task(roster_t // Add a child of an existing entry. pth.push_back(new_component(rng)); - left_er->attach_node(left_nid, pth); - right_er->attach_node(right_nid, pth); + left_er->attach_node(left_nid, file_path(pth)); + right_er->attach_node(right_nid, file_path(pth)); } } @@ -4936,7 +4927,8 @@ UNIT_TEST(roster, unify_rosters_end_to_e roster_t has_not_roster; MM(has_not_roster); marking_map has_not_markings; MM(has_not_markings); { - has_not_roster.attach_node(has_not_roster.create_dir_node(nis), split("")); + has_not_roster.attach_node(has_not_roster.create_dir_node(nis), + file_path()); marking_t root_marking; root_marking.birth_revision = old_rid; root_marking.parent_name = singleton(old_rid); @@ -4949,7 +4941,7 @@ UNIT_TEST(roster, unify_rosters_end_to_e node_id new_id; { new_id = has_roster.create_file_node(my_fid, nis); - has_roster.attach_node(new_id, split("foo")); + has_roster.attach_node(new_id, file_path_internal("foo")); marking_t file_marking; file_marking.birth_revision = has_rid; file_marking.parent_name = file_marking.file_content = singleton(has_rid); @@ -4957,7 +4949,7 @@ UNIT_TEST(roster, unify_rosters_end_to_e } cset add_cs; MM(add_cs); - safe_insert(add_cs.files_added, make_pair(split("foo"), my_fid)); + safe_insert(add_cs.files_added, make_pair(file_path_internal("foo"), my_fid)); cset no_add_cs; MM(no_add_cs); // added in left, then merged @@ -4970,7 +4962,7 @@ UNIT_TEST(roster, unify_rosters_end_to_e singleton(has_not_rid), new_rid, new_roster, new_markings, nis); - I(new_roster.get_node(split("foo"))->self == new_id); + I(new_roster.get_node(file_path_internal("foo"))->self == new_id); } // added in right, then merged { @@ -4982,7 +4974,7 @@ UNIT_TEST(roster, unify_rosters_end_to_e singleton(has_rid), new_rid, new_roster, new_markings, nis); - I(new_roster.get_node(split("foo"))->self == new_id); + I(new_roster.get_node(file_path_internal("foo"))->self == new_id); } // added in merge // this is a little "clever", it uses the same has_not_roster twice, but the @@ -4996,8 +4988,8 @@ UNIT_TEST(roster, unify_rosters_end_to_e singleton(has_rid), new_rid, new_roster, new_markings, nis); - I(new_roster.get_node(split("foo"))->self - != has_roster.get_node(split("foo"))->self); + I(new_roster.get_node(file_path_internal("foo"))->self + != has_roster.get_node(file_path_internal("foo"))->self); } L(FL("TEST: end checking unification of rosters (end to end, ids)")); } @@ -5019,25 +5011,25 @@ UNIT_TEST(roster, unify_rosters_end_to_e marking_map first_markings; MM(first_markings); node_id foo_id; { - first_roster.attach_node(first_roster.create_dir_node(nis), split("")); + first_roster.attach_node(first_roster.create_dir_node(nis), file_path()); marking_t marking; marking.birth_revision = old_rid; marking.parent_name = singleton(old_rid); safe_insert(first_markings, make_pair(first_roster.root()->self, marking)); foo_id = first_roster.create_file_node(my_fid, nis); - first_roster.attach_node(foo_id, split("foo")); + first_roster.attach_node(foo_id, file_path_internal("foo")); marking.file_content = singleton(old_rid); safe_insert(first_markings, - make_pair(first_roster.get_node(split("foo"))->self, marking)); + make_pair(first_roster.get_node(file_path_internal("foo"))->self, marking)); } roster_t second_roster = first_roster; MM(second_roster); marking_map second_markings = first_markings; MM(second_markings); { second_roster.attach_node(second_roster.create_file_node(my_fid, nis), - split("bar")); - safe_insert(second_roster.get_node(split("bar"))->attrs, + file_path_internal("bar")); + safe_insert(second_roster.get_node(file_path_internal("bar"))->attrs, make_pair(attr_key("testbar"), make_pair(false, attr_value()))); marking_t marking; marking.birth_revision = second_rid; @@ -5045,7 +5037,7 @@ UNIT_TEST(roster, unify_rosters_end_to_e safe_insert(marking.attrs, make_pair(attr_key("testbar"), singleton(second_rid))); safe_insert(second_markings, - make_pair(second_roster.get_node(split("bar"))->self, marking)); + make_pair(second_roster.get_node(file_path_internal("bar"))->self, marking)); } // put in the attrs on foo @@ -5061,7 +5053,7 @@ UNIT_TEST(roster, unify_rosters_end_to_e } cset add_cs; MM(add_cs); - safe_insert(add_cs.files_added, make_pair(split("bar"), my_fid)); + safe_insert(add_cs.files_added, make_pair(file_path_internal("bar"), my_fid)); cset no_add_cs; MM(no_add_cs); { @@ -5073,10 +5065,10 @@ UNIT_TEST(roster, unify_rosters_end_to_e singleton(second_rid), new_rid, new_roster, new_markings, nis); - I(new_roster.get_node(split("foo"))->attrs.size() == 2); - I(new_roster.get_node(split("bar"))->attrs - == second_roster.get_node(split("bar"))->attrs); - I(new_roster.get_node(split("bar"))->attrs.size() == 1); + I(new_roster.get_node(file_path_internal("foo"))->attrs.size() == 2); + I(new_roster.get_node(file_path_internal("bar"))->attrs + == second_roster.get_node(file_path_internal("bar"))->attrs); + I(new_roster.get_node(file_path_internal("bar"))->attrs.size() == 1); } { roster_t new_roster; MM(new_roster); @@ -5087,10 +5079,10 @@ UNIT_TEST(roster, unify_rosters_end_to_e singleton(first_rid), new_rid, new_roster, new_markings, nis); - I(new_roster.get_node(split("foo"))->attrs.size() == 2); - I(new_roster.get_node(split("bar"))->attrs - == second_roster.get_node(split("bar"))->attrs); - I(new_roster.get_node(split("bar"))->attrs.size() == 1); + I(new_roster.get_node(file_path_internal("foo"))->attrs.size() == 2); + I(new_roster.get_node(file_path_internal("bar"))->attrs + == second_roster.get_node(file_path_internal("bar"))->attrs); + I(new_roster.get_node(file_path_internal("bar"))->attrs.size() == 1); } L(FL("TEST: end checking unification of rosters (end to end, attr corpses)")); ============================================================ --- roster_merge.cc 275a8079ced7fd414802f69fb1d1d7f7cfdb23a5 +++ roster_merge.cc e4337633b15ec3ba3f9c9d47e72e955aa2a972f5 @@ -313,9 +313,7 @@ namespace c.nid1 = nid; c.nid2 = result.roster.root()->self; c.parent_name = make_pair(parent, name); - split_path root_sp; - file_path().split(root_sp); - result.roster.detach_node(root_sp); + result.roster.detach_node(file_path()); result.rename_target_conflicts.push_back(c); return; } @@ -689,14 +687,6 @@ roster_merge(roster_t const & left_paren // between-node name conflict + causes missing root dir // two nodes that both want "" -split_path -split(string const & s) -{ - split_path sp; - file_path_internal(s).split(sp); - return sp; -} - typedef enum { scalar_a, scalar_b, scalar_conflict } scalar_val; template <> void @@ -790,10 +780,10 @@ struct base_scalar {} void - make_dir(string const & name, node_id nid, roster_t & r, marking_map & markings) + make_dir(char const * name, node_id nid, roster_t & r, marking_map & markings) { r.create_dir_node(nid); - r.attach_node(nid, split(name)); + r.attach_node(nid, file_path_internal(name)); marking_t marking; marking.birth_revision = root_rid; marking.parent_name.insert(root_rid); @@ -801,10 +791,10 @@ struct base_scalar } void - make_file(string const & name, node_id nid, roster_t & r, marking_map & markings) + make_file(char const * name, node_id nid, roster_t & r, marking_map & markings) { r.create_file_node(arbitrary_file, nid); - r.attach_node(nid, split(name)); + r.attach_node(nid, file_path_internal(name)); marking_t marking; marking.birth_revision = root_rid; marking.parent_name.insert(root_rid); @@ -821,8 +811,8 @@ struct file_scalar : public virtual base struct file_scalar : public virtual base_scalar { - split_path thing_name; - file_scalar() : thing_name(split("thing")) + file_path thing_name; + file_scalar() : thing_name(file_path_internal("thing")) {} void @@ -835,8 +825,8 @@ struct dir_scalar : public virtual base_ struct dir_scalar : public virtual base_scalar { - split_path thing_name; - dir_scalar() : thing_name(split("thing")) + file_path thing_name; + dir_scalar() : thing_name(file_path_internal("thing")) {} void @@ -849,10 +839,11 @@ struct name_shared_stuff : public virtua struct name_shared_stuff : public virtual base_scalar { - virtual split_path path_for(scalar_val val) = 0; + virtual file_path path_for(scalar_val val) = 0; path_component pc_for(scalar_val val) { - split_path sp = path_for(val); + split_path sp; + path_for(val).split(sp); return idx(sp, sp.size() - 1); } virtual node_id parent_for(scalar_val val) = 0; @@ -867,10 +858,8 @@ struct name_shared_stuff : public virtua case scalar_a: case scalar_b: { file_path fp; - split_path name; result.roster.get_name(thing_nid, fp); - fp.split(name); - I(name == path_for(expected_val)); + I(fp == path_for(expected_val)); } break; case scalar_conflict: @@ -883,7 +872,7 @@ struct name_shared_stuff : public virtua // resolve the conflict, thus making sure that resolution works and // that this was the only conflict signaled // attach implicitly checks that we were already detached - result.roster.attach_node(thing_nid, split("thing")); + result.roster.attach_node(thing_nid, file_path_internal("thing")); result.node_name_conflicts.pop_back(); break; } @@ -898,10 +887,10 @@ struct basename_scalar : public name_sha template struct basename_scalar : public name_shared_stuff, public T { - virtual split_path path_for(scalar_val val) + virtual file_path path_for(scalar_val val) { I(val != scalar_conflict); - return split((val == scalar_a) ? "a" : "b"); + return file_path_internal((val == scalar_a) ? "a" : "b"); } virtual node_id parent_for(scalar_val val) { @@ -929,10 +918,10 @@ struct parent_scalar : public virtual na parent_scalar() : a_dir_nid(nis.next()), b_dir_nid(nis.next()) {} - virtual split_path path_for(scalar_val val) + virtual file_path path_for(scalar_val val) { I(val != scalar_conflict); - return split((val == scalar_a) ? "a/thing" : "b/thing"); + return file_path_internal((val == scalar_a) ? "a/thing" : "b/thing"); } virtual node_id parent_for(scalar_val val) { @@ -978,7 +967,6 @@ struct attr_scalar : public virtual base // NB result is writeable -- we can scribble on it roster_merge_result & result, scalar_val expected_val) { - split_path name; switch (expected_val) { case scalar_a: case scalar_b: @@ -1030,7 +1018,6 @@ struct file_content_scalar : public virt // NB result is writeable -- we can scribble on it roster_merge_result & result, scalar_val expected_val) { - split_path name; switch (expected_val) { case scalar_a: case scalar_b: @@ -1215,7 +1202,7 @@ make_dir(roster_t & r, marking_map & mar string const & name, node_id nid) { r.create_dir_node(nid); - r.attach_node(nid, split(name)); + r.attach_node(nid, file_path_internal(name)); marking_t marking; marking.birth_revision = birth_rid; marking.parent_name.insert(parent_name_rid); @@ -1230,7 +1217,7 @@ make_file(roster_t & r, marking_map & ma node_id nid) { r.create_file_node(content, nid); - r.attach_node(nid, split(name)); + r.attach_node(nid, file_path_internal(name)); marking_t marking; marking.birth_revision = birth_rid; marking.parent_name.insert(parent_name_rid); @@ -1436,10 +1423,10 @@ struct simple_rename_target_conflict : p rename_target_conflict const & c = idx(result.rename_target_conflicts, 0); I((c.nid1 == left_nid && c.nid2 == right_nid) || (c.nid1 == right_nid && c.nid2 == left_nid)); - I(c.parent_name == make_pair(root_nid, idx(split("thing"), 1))); + I(c.parent_name == make_pair(root_nid, path_component("thing"))); // this tests that they were detached, implicitly - result.roster.attach_node(left_nid, split("left")); - result.roster.attach_node(right_nid, split("right")); + result.roster.attach_node(left_nid, file_path_internal("left")); + result.roster.attach_node(right_nid, file_path_internal("right")); result.rename_target_conflicts.pop_back(); I(result.is_clean()); result.roster.check_sane(); @@ -1467,10 +1454,10 @@ struct simple_dir_loop_conflict : public { I(!result.is_clean()); directory_loop_conflict const & c = idx(result.directory_loop_conflicts, 0); - I((c.nid == left_top_nid && c.parent_name == make_pair(right_top_nid, idx(split("bottom"), 1))) - || (c.nid == right_top_nid && c.parent_name == make_pair(left_top_nid, idx(split("bottom"), 1)))); + I((c.nid == left_top_nid && c.parent_name == make_pair(right_top_nid, path_component("bottom"))) + || (c.nid == right_top_nid && c.parent_name == make_pair(left_top_nid, path_component("bottom")))); // this tests it was detached, implicitly - result.roster.attach_node(c.nid, split("resolved")); + result.roster.attach_node(c.nid, file_path_internal("resolved")); result.directory_loop_conflicts.pop_back(); I(result.is_clean()); result.roster.check_sane(); @@ -1516,12 +1503,12 @@ struct simple_orphan_conflict : public s b = idx(result.orphaned_node_conflicts, 0); } I(a.nid == a_live_child_nid); - I(a.parent_name == make_pair(a_dead_parent_nid, idx(split("a_child"), 1))); + I(a.parent_name == make_pair(a_dead_parent_nid, path_component("a_child"))); I(b.nid == b_live_child_nid); - I(b.parent_name == make_pair(b_dead_parent_nid, idx(split("b_child"), 1))); + I(b.parent_name == make_pair(b_dead_parent_nid, path_component("b_child"))); // this tests it was detached, implicitly - result.roster.attach_node(a.nid, split("resolved_a")); - result.roster.attach_node(b.nid, split("resolved_b")); + result.roster.attach_node(a.nid, file_path_internal("resolved_a")); + result.roster.attach_node(b.nid, file_path_internal("resolved_b")); result.orphaned_node_conflicts.pop_back(); result.orphaned_node_conflicts.pop_back(); I(result.is_clean()); @@ -1543,7 +1530,7 @@ struct simple_illegal_name_conflict : pu new_root_nid = nis.next(); bad_dir_nid = nis.next(); - left_roster.drop_detached_node(left_roster.detach_node(split(""))); + left_roster.drop_detached_node(left_roster.detach_node(file_path())); safe_erase(left_markings, root_nid); make_dir(left_roster, left_markings, old_rid, left_rid, "", new_root_nid); @@ -1558,7 +1545,7 @@ struct simple_illegal_name_conflict : pu I(c.nid == bad_dir_nid); I(c.parent_name == make_pair(new_root_nid, bookkeeping_root_component)); // this tests it was detached, implicitly - result.roster.attach_node(bad_dir_nid, split("dir_formerly_known_as__MTN")); + result.roster.attach_node(bad_dir_nid, file_path_internal("dir_formerly_known_as__MTN")); result.illegal_name_conflicts.pop_back(); I(result.is_clean()); result.roster.check_sane(); @@ -1577,7 +1564,7 @@ struct simple_missing_root_dir : public { other_root_nid = nis.next(); - left_roster.drop_detached_node(left_roster.detach_node(split(""))); + left_roster.drop_detached_node(left_roster.detach_node(file_path())); safe_erase(left_markings, root_nid); make_dir(left_roster, left_markings, old_rid, old_rid, "", other_root_nid); } @@ -1586,7 +1573,7 @@ struct simple_missing_root_dir : public { I(!result.is_clean()); I(result.missing_root_dir); - result.roster.attach_node(result.roster.create_dir_node(nis), split("")); + result.roster.attach_node(result.roster.create_dir_node(nis), file_path()); result.missing_root_dir = false; I(result.is_clean()); result.roster.check_sane(); @@ -1622,15 +1609,17 @@ struct node_name_plus_helper : public st node_id name_conflict_nid; node_id left_parent, right_parent; path_component left_name, right_name; - void make_nn_conflict(string const & left_path, string const & right_path) + void make_nn_conflict(string const & left, string const & right) { + file_path left_path = file_path_internal(left); + file_path right_path = file_path_internal(right); name_conflict_nid = nis.next(); - make_dir(left_roster, left_markings, old_rid, left_rid, left_path, name_conflict_nid); - left_parent = left_roster.get_node(split(left_path))->parent; - left_name = left_roster.get_node(split(left_path))->name; - make_dir(right_roster, right_markings, old_rid, right_rid, right_path, name_conflict_nid); - right_parent = right_roster.get_node(split(right_path))->parent; - right_name = right_roster.get_node(split(right_path))->name; + make_dir(left_roster, left_markings, old_rid, left_rid, left, name_conflict_nid); + left_parent = left_roster.get_node(left_path)->parent; + left_name = left_roster.get_node(left_path)->name; + make_dir(right_roster, right_markings, old_rid, right_rid, right, name_conflict_nid); + right_parent = right_roster.get_node(right_path)->parent; + right_name = right_roster.get_node(right_path)->name; } void check_nn_conflict() { @@ -1639,7 +1628,7 @@ struct node_name_plus_helper : public st I(c.nid == name_conflict_nid); I(c.left == make_pair(left_parent, left_name)); I(c.right == make_pair(right_parent, right_name)); - result.roster.attach_node(name_conflict_nid, split("totally_other_name")); + result.roster.attach_node(name_conflict_nid, file_path_internal("totally_other_name")); result.node_name_conflicts.pop_back(); I(result.is_clean()); result.roster.check_sane(); @@ -1663,8 +1652,8 @@ struct node_name_plus_rename_target : pu { // there should just be a single conflict on name_conflict_nid, and a and // b should have landed fine - I(result.roster.get_node(split("a"))->self == a_nid); - I(result.roster.get_node(split("b"))->self == b_nid); + I(result.roster.get_node(file_path_internal("a"))->self == a_nid); + I(result.roster.get_node(file_path_internal("b"))->self == b_nid); check_nn_conflict(); } }; @@ -1719,7 +1708,7 @@ struct node_name_plus_illegal_name : pub { new_root_nid = nis.next(); make_dir(left_roster, left_markings, old_rid, old_rid, "new_root", new_root_nid); - right_roster.drop_detached_node(right_roster.detach_node(split(""))); + right_roster.drop_detached_node(right_roster.detach_node(file_path())); safe_erase(right_markings, root_nid); make_dir(right_roster, right_markings, old_rid, right_rid, "", new_root_nid); make_nn_conflict("new_root/_MTN", "foo"); @@ -1742,12 +1731,12 @@ struct node_name_plus_missing_root : pub left_root_nid = nis.next(); right_root_nid = nis.next(); - left_roster.drop_detached_node(left_roster.detach_node(split(""))); + left_roster.drop_detached_node(left_roster.detach_node(file_path())); safe_erase(left_markings, root_nid); make_dir(left_roster, left_markings, old_rid, left_rid, "", left_root_nid); make_dir(left_roster, left_markings, old_rid, left_rid, "right_root", right_root_nid); - right_roster.drop_detached_node(right_roster.detach_node(split(""))); + right_roster.drop_detached_node(right_roster.detach_node(file_path())); safe_erase(right_markings, root_nid); make_dir(right_roster, right_markings, old_rid, right_rid, "", right_root_nid); make_dir(right_roster, right_markings, old_rid, right_rid, "left_root", left_root_nid); @@ -1756,10 +1745,10 @@ struct node_name_plus_missing_root : pub { I(left_c.nid == left_root_nid); I(left_c.left == make_pair(the_null_node, the_null_component)); - I(left_c.right == make_pair(right_root_nid, idx(split("left_root"), 1))); + I(left_c.right == make_pair(right_root_nid, path_component("left_root"))); I(right_c.nid == right_root_nid); - I(right_c.left == make_pair(left_root_nid, idx(split("right_root"), 1))); + I(right_c.left == make_pair(left_root_nid, path_component("right_root"))); I(right_c.right == make_pair(the_null_node, the_null_component)); } virtual void check() @@ -1776,8 +1765,8 @@ struct node_name_plus_missing_root : pub I(result.missing_root_dir); - result.roster.attach_node(left_root_nid, split("")); - result.roster.attach_node(right_root_nid, split("totally_other_name")); + result.roster.attach_node(left_root_nid, file_path()); + result.roster.attach_node(right_root_nid, file_path_internal("totally_other_name")); result.node_name_conflicts.pop_back(); result.node_name_conflicts.pop_back(); result.missing_root_dir = false; @@ -1795,11 +1784,11 @@ struct rename_target_plus_missing_root : left_root_nid = nis.next(); right_root_nid = nis.next(); - left_roster.drop_detached_node(left_roster.detach_node(split(""))); + left_roster.drop_detached_node(left_roster.detach_node(file_path())); safe_erase(left_markings, root_nid); make_dir(left_roster, left_markings, left_rid, left_rid, "", left_root_nid); - right_roster.drop_detached_node(right_roster.detach_node(split(""))); + right_roster.drop_detached_node(right_roster.detach_node(file_path())); safe_erase(right_markings, root_nid); make_dir(right_roster, right_markings, right_rid, right_rid, "", right_root_nid); } @@ -1815,9 +1804,9 @@ struct rename_target_plus_missing_root : // we can't just attach one of these as the root -- see the massive // comment on the old_locations member of roster_t, in roster.hh. - result.roster.attach_node(result.roster.create_dir_node(nis), split("")); - result.roster.attach_node(left_root_nid, split("totally_left_name")); - result.roster.attach_node(right_root_nid, split("totally_right_name")); + result.roster.attach_node(result.roster.create_dir_node(nis), file_path()); + result.roster.attach_node(left_root_nid, file_path_internal("totally_left_name")); + result.roster.attach_node(right_root_nid, file_path_internal("totally_right_name")); result.rename_target_conflicts.pop_back(); result.missing_root_dir = false; I(result.is_clean()); ============================================================ --- work.cc 8a409fe325bc29ba61477021c35f5d70c0a2eb11 +++ work.cc 4c903c77d9fa1b12223c6586c92b3d87462dd730 @@ -523,30 +523,24 @@ workspace_itemizer::workspace_itemizer(r node_id_source & nis) : roster(roster), known(paths), nis(nis) { - split_path root_path; - file_path().split(root_path); node_id root_nid = roster.create_dir_node(nis); - roster.attach_node(root_nid, root_path); + roster.attach_node(root_nid, file_path_internal("")); } bool workspace_itemizer::visit_dir(file_path const & path) { - split_path sp; - path.split(sp); node_id nid = roster.create_dir_node(nis); - roster.attach_node(nid, sp); + roster.attach_node(nid, path); return known.find(path) != known.end(); } void workspace_itemizer::visit_file(file_path const & path) { - split_path sp; - path.split(sp); file_id fid; node_id nid = roster.create_file_node(fid, nis); - roster.attach_node(nid, sp); + roster.attach_node(nid, path); } @@ -591,18 +585,14 @@ addition_builder::add_node_for(file_path } I(nid != the_null_node); - split_path sp; - path.split(sp); - er.attach_node(nid, sp); + er.attach_node(nid, path); map attrs; lua.hook_init_attributes(path, attrs); if (attrs.size() > 0) - { - for (map::const_iterator i = attrs.begin(); - i != attrs.end(); ++i) - er.set_attr(sp, attr_key(i->first), attr_value(i->second)); - } + for (map::const_iterator i = attrs.begin(); + i != attrs.end(); ++i) + er.set_attr(path, attr_key(i->first), attr_value(i->second)); } @@ -622,26 +612,26 @@ addition_builder::visit_file(file_path c return; } - split_path sp; - path.split(sp); - if (ros.has_node(sp)) + if (ros.has_node(path)) { - if (sp.size() > 1) + if (!path.empty()) P(F("skipping %s, already accounted for in workspace") % path); return; } + + I(ros.has_root()); - split_path prefix; - I(ros.has_root()); + split_path sp, prefix; + path.split(sp); for (split_path::const_iterator i = sp.begin(); i != sp.end(); ++i) { prefix.push_back(*i); - if (!ros.has_node(prefix)) + if (!ros.has_node(file_path(prefix))) { P(F("adding %s to workspace manifest") % file_path(prefix)); - add_node_for(prefix); + add_node_for(file_path(prefix)); } - if (!is_dir_t(ros.get_node(prefix))) + if (!is_dir_t(ros.get_node(file_path(prefix)))) { N(prefix == sp, F("cannot add %s, because %s is recorded as a file " @@ -693,7 +683,7 @@ struct simulated_working_tree : public e roster_t & workspace; node_id_source & nis; - set blocked_paths; + set blocked_paths; map nid_map; int conflicts; @@ -918,9 +908,7 @@ simulated_working_tree::detach_node(file node_id simulated_working_tree::detach_node(file_path const & src) { - split_path sp; - src.split(sp); - node_id nid = workspace.detach_node(sp); + node_id nid = workspace.detach_node(src); nid_map.insert(make_pair(nid, src)); return nid; } @@ -961,30 +949,37 @@ simulated_working_tree::attach_node(node // represent paths that *may* block the checkout. however to represent // these we *must* have a root node in the roster which will *always* // block us. so here we check for that case and avoid it. - split_path dsts; - dst.split(dsts); - - if (workspace_root(dsts) && workspace.has_root()) + if (workspace_root(dst) && workspace.has_root()) return; - if (workspace.has_node(dsts)) + if (workspace.has_node(dst)) { W(F("attach node %d blocked by unversioned path '%s'") % nid % dst); - blocked_paths.insert(dsts); + blocked_paths.insert(dst); conflicts++; } + else if (dst.empty()) + { + // the parent of the workspace root cannot be in the blocked set + // this attach would have been caught above if it were a problem + workspace.attach_node(nid, dst); + } else { + split_path dsts; + dst.split(dsts); + split_path dirname; path_component basename; dirname_basename(dsts, dirname, basename); - if (blocked_paths.find(dirname) == blocked_paths.end()) - workspace.attach_node(nid, dsts); + if (blocked_paths.find(file_path(dirname)) == blocked_paths.end()) + workspace.attach_node(nid, dst); else { - W(F("attach node %d blocked by blocked parent '%s'") % nid % dst); - blocked_paths.insert(dsts); + W(F("attach node %d blocked by blocked parent '%s'") + % nid % file_path(dirname)); + blocked_paths.insert(dst); } } } @@ -1037,7 +1032,7 @@ add_parent_dirs(file_path const & dst, r dirname_basename(sp, dirname, basename); // FIXME: this is a somewhat odd way to use the builder - build.visit_dir(dirname); + build.visit_dir(file_path(dirname)); } inline static bool @@ -1429,89 +1424,80 @@ void } void -workspace::perform_rename(set const & src_paths, - file_path const & dst_path, +workspace::perform_rename(set const & srcs, + file_path const & dst, bool bookkeep_only) { temp_node_id_source nis; roster_t new_roster; MM(new_roster); - split_path dst; - set srcs; - set< pair > renames; + set< pair > renames; - I(!src_paths.empty()); + I(!srcs.empty()); get_current_roster_shape(new_roster, nis); - dst_path.split(dst); - - if (src_paths.size() == 1 && !new_roster.has_node(dst)) + // validation. it's okay if the target exists as a file; we just won't + // clobber it (in !--bookkeep-only mode). similarly, it's okay if the + // source does not exist as a file. + if (srcs.size() == 1 && !new_roster.has_node(dst)) { // "rename SRC DST" case - split_path s; - src_paths.begin()->split(s); - N(new_roster.has_node(s), - F("source file %s is not versioned") % s); - N(get_path_status(dst_path) != path::directory, - F("destination name %s already exists as an unversioned directory") % dst); - renames.insert( make_pair(s, dst) ); + file_path const & src = *srcs.begin(); + + N(!directory_exists(dst), + F("destination dir %s/ is not versioned (perhaps add it?)") % dst); + + N(!src.empty(), + F("cannot rename the workspace root (try '%s pivot_root' instead)") + % ui.prog_name); + N(new_roster.has_node(src), + F("source file %s is not versioned") % src); + + renames.insert(make_pair(src, dst)); add_parent_dirs(dst, new_roster, nis, db, lua); } else { - // "rename SRC1 SRC2 DST" case + // "rename SRC1 [SRC2 ...] DSTDIR" case N(new_roster.has_node(dst), - F("destination dir %s/ is not versioned (perhaps add it?)") % dst_path); + F("destination dir %s/ is not versioned (perhaps add it?)") % dst); N(is_dir_t(new_roster.get_node(dst)), - F("destination %s is an existing file in current revision") % dst_path); + (srcs.size() > 1 + ? F("destination %s is a file, not a directory") + : F("destination %s already exists in the workspace manifest")) + % dst); - for (set::const_iterator i = src_paths.begin(); - i != src_paths.end(); i++) + for (set::const_iterator i = srcs.begin(); + i != srcs.end(); i++) { - split_path s; - i->split(s); - // TODO "rename . foo/" might be valid? Or should it already have been - // normalised..., in which case it might be an I(). - N(!s.empty(), - F("empty path %s is not allowed") % *i); + N(!i->empty(), + F("cannot rename the workspace root (try '%s pivot_root' instead)") + % ui.prog_name); + N(new_roster.has_node(*i), + F("source file %s is not versioned") % *i); - path_component src_basename = s.back(); - split_path d(dst); - d.push_back(src_basename); - renames.insert( make_pair(s, d) ); - } - } + path_component base; + split_path s, dir; + i->split(s); + dirname_basename(s, dir, base); - // one iteration to check for existing/missing files - for (set< pair >::const_iterator i = renames.begin(); - i != renames.end(); i++) - { - N(new_roster.has_node(i->first), - F("%s does not exist in current manifest") % file_path(i->first)); + file_path d = dst / base(); + N(!new_roster.has_node(d), + F("destination %s already exists in the workspace manifest") % d); - N(!new_roster.has_node(i->second), - F("destination %s already exists in current manifest") % file_path(i->second)); - - split_path parent; - path_component basename; - dirname_basename(i->second, parent, basename); - N(new_roster.has_node(parent), - F("destination directory %s does not exist in current manifest") % file_path(parent)); - N(is_dir_t(new_roster.get_node(parent)), - F("destination directory %s is not a directory") % file_path(parent)); + renames.insert(make_pair(*i, d)); + } } // do the attach/detaching - for (set< pair >::const_iterator i = renames.begin(); + for (set< pair >::const_iterator i = renames.begin(); i != renames.end(); i++) { node_id nid = new_roster.detach_node(i->first); new_roster.attach_node(nid, i->second); - P(F("renaming %s to %s in workspace manifest") - % file_path(i->first) - % file_path(i->second)); + P(F("renaming %s to %s in workspace manifest") % i->first % i->second); } parent_map parents; @@ -1522,34 +1508,34 @@ workspace::perform_rename(set put_work_rev(new_work); if (!bookkeep_only) - { - for (set< pair >::const_iterator i = renames.begin(); - i != renames.end(); i++) - { - file_path s(i->first); - file_path d(i->second); - // silently skip files where src doesn't exist or dst does - bool have_src = path_exists(s); - bool have_dst = path_exists(d); - if (have_src && !have_dst) - { - move_path(s, d); - } - else if (!have_src && !have_dst) - { - W(F("%s doesn't exist in workspace, skipping") % s); - } - else if (have_src && have_dst) - { - W(F("destination %s already exists in workspace, skipping filesystem rename") % d); - } - else - { - W(F("skipping move_path in filesystem %s->%s, source doesn't exist, destination does") - % s % d); - } - } - } + for (set< pair >::const_iterator i = renames.begin(); + i != renames.end(); i++) + { + file_path const & s(i->first); + file_path const & d(i->second); + // silently skip files where src doesn't exist or dst does + bool have_src = path_exists(s); + bool have_dst = path_exists(d); + if (have_src && !have_dst) + { + move_path(s, d); + } + else if (!have_src && !have_dst) + { + W(F("%s doesn't exist in workspace, skipping") % s); + } + else if (have_src && have_dst) + { + W(F("destination %s already exists in workspace, " + "skipping filesystem rename") % d); + } + else + { + W(F("%s doesn't exist in workspace and %s does, " + "skipping filesystem rename") % s % d); + } + } + update_any_attrs(); } @@ -1558,26 +1544,21 @@ workspace::perform_pivot_root(file_path file_path const & put_old, bool bookkeep_only) { - split_path new_root_sp, put_old_sp, root_sp; - new_root.split(new_root_sp); - put_old.split(put_old_sp); - file_path().split(root_sp); - temp_node_id_source nis; roster_t new_roster; MM(new_roster); get_current_roster_shape(new_roster, nis); I(new_roster.has_root()); - N(new_roster.has_node(new_root_sp), - F("proposed new root directory '%s' is not versioned or does not exist") % new_root); - N(is_dir_t(new_roster.get_node(new_root_sp)), + N(new_roster.has_node(new_root), + F("proposed new root directory '%s' is not versioned or does not exist") + % new_root); + N(is_dir_t(new_roster.get_node(new_root)), F("proposed new root directory '%s' is not a directory") % new_root); { - split_path new_root__MTN; - (new_root / bookkeeping_root.as_internal()).split(new_root__MTN); - N(!new_roster.has_node(new_root__MTN), - F("proposed new root directory '%s' contains illegal path %s") % new_root % bookkeeping_root); + N(!new_roster.has_node(new_root / bookkeeping_root.as_internal()), + F("proposed new root directory '%s' contains illegal path %s") + % new_root % bookkeeping_root); } { @@ -1585,20 +1566,21 @@ workspace::perform_pivot_root(file_path split_path current_path_to_put_old_sp, current_path_to_put_old_parent_sp; path_component basename; current_path_to_put_old.split(current_path_to_put_old_sp); - dirname_basename(current_path_to_put_old_sp, current_path_to_put_old_parent_sp, basename); - N(new_roster.has_node(current_path_to_put_old_parent_sp), + dirname_basename(current_path_to_put_old_sp, + current_path_to_put_old_parent_sp, basename); + N(new_roster.has_node(file_path(current_path_to_put_old_parent_sp)), F("directory '%s' is not versioned or does not exist") % file_path(current_path_to_put_old_parent_sp)); - N(is_dir_t(new_roster.get_node(current_path_to_put_old_parent_sp)), + N(is_dir_t(new_roster.get_node(file_path(current_path_to_put_old_parent_sp))), F("'%s' is not a directory") % file_path(current_path_to_put_old_parent_sp)); - N(!new_roster.has_node(current_path_to_put_old_sp), + N(!new_roster.has_node(current_path_to_put_old), F("'%s' is in the way") % current_path_to_put_old); } cset cs; - safe_insert(cs.nodes_renamed, make_pair(root_sp, put_old_sp)); - safe_insert(cs.nodes_renamed, make_pair(new_root_sp, root_sp)); + safe_insert(cs.nodes_renamed, make_pair(file_path_internal(""), put_old)); + safe_insert(cs.nodes_renamed, make_pair(new_root, file_path_internal(""))); { editable_roster_base e(new_roster, nis);