# # # patch "automate.cc" # from [7f9e5ead627f71b092a15b9919bd3f2f721dfb85] # to [45bb2a401fc728830258f56c98a9031b0711d281] # # patch "cmd_diff_log.cc" # from [197c4f6f8a28fb1d57026c715693a936ccba2c98] # to [94fd0088550fa4c89967c03c33fdefa54bf15a67] # # patch "cmd_ws_commit.cc" # from [1b33fbd6f0a59bce2ece592676754bccdfa06683] # to [52864991081a260cdc9d7d08b8e5e8d4d855ddfd] # # patch "cset.cc" # from [00c69570bb60a3c49337e350ab39816741f6764a] # to [46e1d0a2704497281540fdb8eadf595557a8de1b] # # patch "cset.hh" # from [eedb0328724138427340bbd88a8ebc48f2f29273] # to [f395ff8f90e463ab9744db5a1946f23f78034c23] # # patch "database.cc" # from [8fc87fee1363699af5621f703b85ae288b499491] # to [00303a4bcbf958f20bf32f244fa8d7997a54d749] # # patch "enumerator.cc" # from [eec6cead8d287bcb00376bb9f2ed8a48fad7f229] # to [103045a099579dcbbe7d7044798946522f8b0c91] # # patch "paths.cc" # from [ffbea7c9012969491367d66bbd26d8da87860734] # to [51e6ebc6e9079807485d8359c8e17726ed74619c] # # patch "paths.hh" # from [95e2d4782ab7e04859e292f8b92aad4ead046b83] # to [3c3ad14d890d72a47e359d698e687520d594c13c] # # patch "roster.cc" # from [2d66e04b7ca82b71b11f9aa3d8263ff0a193c013] # to [84e18891eff147958ea6547f9d26d7679afa3cc0] # # patch "roster.hh" # from [58f56b5761388f0c4a35436532a64b6c7812b755] # to [2c54cc36a5c5c34be76013593921b451513a33a8] # # patch "work.cc" # from [66159e9dae0264bfc4b066b87f8cf6888900cfb5] # to [ba49d44159b566894eafbc7db222b1716505dbb2] # ============================================================ --- automate.cc 7f9e5ead627f71b092a15b9919bd3f2f721dfb85 +++ automate.cc 45bb2a401fc728830258f56c98a9031b0711d281 @@ -518,19 +518,19 @@ struct inventory_item pre_id(0), post_id(0) {} }; -typedef map inventory_map; -typedef map rename_map; // this might be good in cset.hh -typedef map addition_map; // ditto +typedef map inventory_map; +typedef map rename_map; // this might be good in cset.hh +typedef map addition_map; // ditto static void inventory_pre_state(inventory_map & inventory, - path_set const & paths, + set const & paths, inventory_item::pstate pre_state, size_t rename_id) { - for (path_set::const_iterator i = paths.begin(); i != paths.end(); i++) + for (set::const_iterator i = paths.begin(); i != paths.end(); i++) { - L(FL("%d %d %s") % inventory[*i].pre_state % pre_state % file_path(*i)); + L(FL("%d %d %s") % inventory[*i].pre_state % pre_state % *i); I(inventory[*i].pre_state == inventory_item::UNCHANGED_PATH); inventory[*i].pre_state = pre_state; if (rename_id != 0) @@ -543,14 +543,13 @@ inventory_post_state(inventory_map & inv static void inventory_post_state(inventory_map & inventory, - path_set const & paths, + set const & paths, inventory_item::pstate post_state, size_t rename_id) { - for (path_set::const_iterator i = paths.begin(); i != paths.end(); i++) + for (set::const_iterator i = paths.begin(); i != paths.end(); i++) { - L(FL("%d %d %s") % inventory[*i].post_state - % post_state % file_path(*i)); + L(FL("%d %d %s") % inventory[*i].post_state % post_state % *i); I(inventory[*i].post_state == inventory_item::UNCHANGED_PATH); inventory[*i].post_state = post_state; if (rename_id != 0) @@ -579,8 +578,8 @@ inventory_renames(inventory_map & invent inventory_renames(inventory_map & inventory, rename_map const & renames) { - path_set old_name; - path_set new_name; + set old_name; + set new_name; static size_t rename_id = 1; @@ -603,7 +602,8 @@ static void } static void -extract_added_file_paths(addition_map const & additions, path_set & paths) +extract_added_file_paths(addition_map const & additions, + set & paths) { for (addition_map::const_iterator i = additions.begin(); i != additions.end(); ++i) @@ -684,7 +684,7 @@ CMD_AUTOMATE(inventory, "", // recorded on the filesystem (because get_..._shape was used to // build it). - path_set nodes_added(cs.dirs_added); + set nodes_added(cs.dirs_added); extract_added_file_paths(cs.files_added, nodes_added); inventory_pre_state(inventory, cs.nodes_deleted, @@ -720,25 +720,27 @@ CMD_AUTOMATE(inventory, "", for (inventory_map::const_iterator i = inventory.begin(); i != inventory.end(); ++i) { + string path_suffix; + split_path sp; - string path_suffix; + i->first.split(sp); // ensure that directory nodes always get a trailing slash even // if they're missing from the workspace or have been deleted // but skip the root node which do not get this trailing slash appended - if (curr.has_node(i->first)) + if (curr.has_node(sp)) { - node_t n = curr.get_node(i->first); + node_t n = curr.get_node(sp); if (is_root_dir_t(n)) continue; if (is_dir_t(n)) path_suffix = "/"; } - else if (base.has_node(i->first)) + else if (base.has_node(sp)) { - node_t n = base.get_node(i->first); + node_t n = base.get_node(sp); if (is_root_dir_t(n)) continue; if (is_dir_t(n)) path_suffix = "/"; } - else if (directory_exists(file_path(i->first))) + else if (directory_exists(i->first)) { path_suffix = "/"; } ============================================================ --- cmd_diff_log.cc 197c4f6f8a28fb1d57026c715693a936ccba2c98 +++ cmd_diff_log.cc 94fd0088550fa4c89967c03c33fdefa54bf15a67 @@ -92,15 +92,15 @@ print_indented_set(ostream & os, static void print_indented_set(ostream & os, - path_set const & s, + set const & s, size_t max_cols) { size_t cols = 8; os << " "; - for (path_set::const_iterator i = s.begin(); + for (set::const_iterator i = s.begin(); i != s.end(); i++) { - const string str = lexical_cast(file_path(*i)); + const string str = lexical_cast(*i); if (cols > 8 && cols + str.size() + 1 >= max_cols) { cols = 8; @@ -125,17 +125,17 @@ changes_summary::print(ostream & os, siz if (! cs.nodes_renamed.empty()) { os << _("Renamed entries:") << '\n'; - for (map::const_iterator + for (map::const_iterator i = cs.nodes_renamed.begin(); i != cs.nodes_renamed.end(); i++) - os << " " << file_path(i->first) - << " to " << file_path(i->second) << '\n'; + os << " " << i->first + << " to " << i->second << '\n'; } if (! cs.files_added.empty()) { - path_set tmp; - for (map::const_iterator + set tmp; + for (map::const_iterator i = cs.files_added.begin(); i != cs.files_added.end(); ++i) tmp.insert(i->first); @@ -151,8 +151,8 @@ changes_summary::print(ostream & os, siz if (! cs.deltas_applied.empty()) { - path_set tmp; - for (map >::const_iterator + set tmp; + for (map >::const_iterator i = cs.deltas_applied.begin(); i != cs.deltas_applied.end(); ++i) tmp.insert(i->first); @@ -162,13 +162,13 @@ changes_summary::print(ostream & os, siz if (! cs.attrs_set.empty() || ! cs.attrs_cleared.empty()) { - path_set tmp; - for (set >::const_iterator + set tmp; + for (set >::const_iterator i = cs.attrs_cleared.begin(); i != cs.attrs_cleared.end(); ++i) tmp.insert(i->first); - for (map, attr_value>::const_iterator + for (map, attr_value>::const_iterator i = cs.attrs_set.begin(); i != cs.attrs_set.end(); ++i) tmp.insert(i->first.first); @@ -183,7 +183,7 @@ do_external_diff(cset const & cs, app_state & app, bool new_is_archived) { - for (map >::const_iterator + for (map >::const_iterator i = cs.deltas_applied.begin(); i != cs.deltas_applied.end(); ++i) { @@ -202,7 +202,7 @@ do_external_diff(cset const & cs, } else { - read_data(file_path(delta_entry_path(i)), data_new); + read_data(delta_entry_path(i), data_new); } bool is_binary = false; @@ -210,7 +210,7 @@ do_external_diff(cset const & cs, guess_binary(data_new())) is_binary = true; - app.lua.hook_external_diff(file_path(delta_entry_path(i)), + app.lua.hook_external_diff(delta_entry_path(i), data_old, data_new, is_binary, @@ -226,13 +226,13 @@ dump_diffs(cset const & cs, app_state & app, bool new_is_archived, std::ostream & output, - set const & paths, + set const & paths, bool limit_paths = false) { // 60 is somewhat arbitrary, but less than 80 string patch_sep = string(60, '='); - for (map::const_iterator + for (map::const_iterator i = cs.files_added.begin(); i != cs.files_added.end(); ++i) { @@ -251,7 +251,7 @@ dump_diffs(cset const & cs, } else { - read_data(file_path(i->first), unpacked); + read_data(i->first, unpacked); } std::string pattern(""); @@ -259,24 +259,24 @@ dump_diffs(cset const & cs, app.lua.hook_get_encloser_pattern(file_path(i->first), pattern); - make_diff(file_path(i->first).as_internal(), - file_path(i->first).as_internal(), + make_diff(i->first.as_internal(), + i->first.as_internal(), i->second, i->second, data(), unpacked, output, app.opts.diff_format, pattern); } - map reverse_rename_map; + map reverse_rename_map; - for (map::const_iterator + for (map::const_iterator i = cs.nodes_renamed.begin(); i != cs.nodes_renamed.end(); ++i) { reverse_rename_map.insert(make_pair(i->second, i->first)); } - for (map >::const_iterator + for (map >::const_iterator i = cs.deltas_applied.begin(); i != cs.deltas_applied.end(); ++i) { @@ -299,23 +299,23 @@ dump_diffs(cset const & cs, } else { - read_data(file_path(delta_entry_path(i)), data_new); + read_data(delta_entry_path(i), data_new); } - split_path dst_path = delta_entry_path(i); - split_path src_path = dst_path; - map::const_iterator re; + file_path dst_path = delta_entry_path(i); + file_path src_path = dst_path; + map::const_iterator re; re = reverse_rename_map.find(dst_path); if (re != reverse_rename_map.end()) src_path = re->second; std::string pattern(""); if (!app.opts.no_show_encloser) - app.lua.hook_get_encloser_pattern(file_path(src_path), + app.lua.hook_get_encloser_pattern(src_path, pattern); - make_diff(file_path(src_path).as_internal(), - file_path(dst_path).as_internal(), + make_diff(src_path.as_internal(), + dst_path.as_internal(), delta_entry_src(i), delta_entry_dst(i), data_old, data_new, @@ -329,7 +329,7 @@ dump_diffs(cset const & cs, bool new_is_archived, std::ostream & output) { - set dummy; + set dummy; dump_diffs(cs, app, new_is_archived, output, dummy); } @@ -764,7 +764,7 @@ CMD(log, "log", "", CMD_REF(informative) revision_id const & rid = frontier.top().second; bool print_this = mask.empty(); - set diff_paths; + set diff_paths; if (null_id(rid) || seen.find(rid) != seen.end()) { @@ -822,7 +822,7 @@ CMD(log, "log", "", CMD_REF(informative) { split_path sp; roster.get_name(*n, sp); - diff_paths.insert(sp); + diff_paths.insert(file_path(sp)); } } } ============================================================ --- cmd_ws_commit.cc 1b33fbd6f0a59bce2ece592676754bccdfa06683 +++ cmd_ws_commit.cc 52864991081a260cdc9d7d08b8e5e8d4d855ddfd @@ -53,29 +53,29 @@ revision_summary(revision_t const & rev, if (cs.empty()) out += F(" no changes").str() += '\n'; - for (path_set::const_iterator i = cs.nodes_deleted.begin(); + for (set::const_iterator i = cs.nodes_deleted.begin(); i != cs.nodes_deleted.end(); ++i) out += (F(" dropped %s") % *i).str() += '\n'; - for (map::const_iterator + for (map::const_iterator i = cs.nodes_renamed.begin(); i != cs.nodes_renamed.end(); ++i) out += (F(" renamed %s\n" " to %s") % i->first % i->second).str() += '\n'; - for (path_set::const_iterator i = cs.dirs_added.begin(); + for (set::const_iterator i = cs.dirs_added.begin(); i != cs.dirs_added.end(); ++i) out += (F(" added %s") % *i).str() += '\n'; - for (map::const_iterator i = cs.files_added.begin(); + for (map::const_iterator i = cs.files_added.begin(); i != cs.files_added.end(); ++i) out += (F(" added %s") % i->first).str() += '\n'; - for (map >::const_iterator + for (map >::const_iterator i = cs.deltas_applied.begin(); i != cs.deltas_applied.end(); ++i) out += (F(" patched %s") % (i->first)).str() += '\n'; - for (map, attr_value >::const_iterator + for (map, attr_value >::const_iterator i = cs.attrs_set.begin(); i != cs.attrs_set.end(); ++i) out += (F(" attr on %s\n" " attr %s\n" @@ -83,7 +83,7 @@ revision_summary(revision_t const & rev, % (i->first.first) % (i->first.second) % (i->second) ).str() += "\n"; - for (set >::const_iterator + for (set >::const_iterator i = cs.attrs_cleared.begin(); i != cs.attrs_cleared.end(); ++i) out += (F(" unset on %s\n" " attr %s") @@ -1120,11 +1120,12 @@ CMD(commit, "commit", "ci", CMD_REF(work // process file deltas or new files cset const & cs = edge_changes(edge); - for (map >::const_iterator + for (map >::const_iterator i = cs.deltas_applied.begin(); i != cs.deltas_applied.end(); ++i) { - file_path path(i->first); + file_path path = i->first; + file_id old_content = i->second.first; file_id new_content = i->second.second; @@ -1160,11 +1161,11 @@ CMD(commit, "commit", "ci", CMD_REF(work % old_content % path); } - for (map::const_iterator + for (map::const_iterator i = cs.files_added.begin(); i != cs.files_added.end(); ++i) { - file_path path(i->first); + file_path path = i->first; file_id new_content = i->second; L(FL("inserting full version %s") % new_content); ============================================================ --- cset.cc 00c69570bb60a3c49337e350ab39816741f6764a +++ cset.cc 46e1d0a2704497281540fdb8eadf595557a8de1b @@ -36,8 +36,8 @@ check_normalized(cset const & cs) // no file appears in both the "added" list and the "patched" list { - map::const_iterator a = cs.files_added.begin(); - map >::const_iterator + map::const_iterator a = cs.files_added.begin(); + map >::const_iterator d = cs.deltas_applied.begin(); while (a != cs.files_added.end() && d != cs.deltas_applied.end()) { @@ -55,8 +55,8 @@ check_normalized(cset const & cs) // no file+attr pair appears in both the "set" list and the "cleared" list { - set >::const_iterator c = cs.attrs_cleared.begin(); - map, attr_value>::const_iterator + set >::const_iterator c = cs.attrs_cleared.begin(); + map, attr_value>::const_iterator s = cs.attrs_set.begin(); while (c != cs.attrs_cleared.end() && s != cs.attrs_set.end()) { @@ -98,28 +98,28 @@ detach struct detach { - detach(split_path const & src) + detach(file_path const & src) : src_path(src), reattach(false) {} - detach(split_path const & src, - split_path const & dst) + detach(file_path const & src, + file_path const & dst) : src_path(src), reattach(true), dst_path(dst) {} - split_path src_path; + file_path src_path; bool reattach; - split_path dst_path; + file_path dst_path; bool operator<(struct detach const & other) const { // We sort detach operations bottom-up by src path // SPEEDUP?: simply sort by path.size() rather than full lexicographical // comparison? - return src_path > other.src_path; + return other.src_path < src_path; } }; @@ -127,12 +127,12 @@ attach attach { attach(node_id n, - split_path const & p) + file_path const & p) : node(n), path(p) {} node_id node; - split_path path; + file_path path; bool operator<(struct attach const & other) const { @@ -168,11 +168,11 @@ cset::apply_to(editable_tree & t) const // repeatedly from the same place, so they're impossible anyway, but we need // to error out if someone tries to add them. - for (path_set::const_iterator i = dirs_added.begin(); + for (set::const_iterator i = dirs_added.begin(); i != dirs_added.end(); ++i) safe_insert(attaches, attach(t.create_dir_node(), *i)); - for (map::const_iterator i = files_added.begin(); + for (map::const_iterator i = files_added.begin(); i != files_added.end(); ++i) safe_insert(attaches, attach(t.create_file_node(i->second), i->first)); @@ -181,11 +181,11 @@ cset::apply_to(editable_tree & t) const // existing paths into the set of pending detaches, to be executed // bottom-up. - for (path_set::const_iterator i = nodes_deleted.begin(); + for (set::const_iterator i = nodes_deleted.begin(); i != nodes_deleted.end(); ++i) safe_insert(detaches, detach(*i)); - for (map::const_iterator i = nodes_renamed.begin(); + for (map::const_iterator i = nodes_renamed.begin(); i != nodes_renamed.end(); ++i) safe_insert(detaches, detach(i->first, i->second)); @@ -217,15 +217,15 @@ cset::apply_to(editable_tree & t) const // Execute all the in-place edits - for (map >::const_iterator i = deltas_applied.begin(); + for (map >::const_iterator i = deltas_applied.begin(); i != deltas_applied.end(); ++i) t.apply_delta(i->first, i->second.first, i->second.second); - for (set >::const_iterator i = attrs_cleared.begin(); + for (set >::const_iterator i = attrs_cleared.begin(); i != attrs_cleared.end(); ++i) t.clear_attr(i->first, i->second); - for (map, attr_value>::const_iterator i = attrs_set.begin(); + for (map, attr_value>::const_iterator i = attrs_set.begin(); i != attrs_set.end(); ++i) t.set_attr(i->first.first, i->first.second, i->second); @@ -260,7 +260,7 @@ print_cset(basic_io::printer & printer, print_cset(basic_io::printer & printer, cset const & cs) { - for (path_set::const_iterator i = cs.nodes_deleted.begin(); + for (set::const_iterator i = cs.nodes_deleted.begin(); i != cs.nodes_deleted.end(); ++i) { basic_io::stanza st; @@ -268,7 +268,7 @@ print_cset(basic_io::printer & printer, printer.print_stanza(st); } - for (map::const_iterator i = cs.nodes_renamed.begin(); + for (map::const_iterator i = cs.nodes_renamed.begin(); i != cs.nodes_renamed.end(); ++i) { basic_io::stanza st; @@ -277,7 +277,7 @@ print_cset(basic_io::printer & printer, printer.print_stanza(st); } - for (path_set::const_iterator i = cs.dirs_added.begin(); + for (set::const_iterator i = cs.dirs_added.begin(); i != cs.dirs_added.end(); ++i) { basic_io::stanza st; @@ -285,7 +285,7 @@ print_cset(basic_io::printer & printer, printer.print_stanza(st); } - for (map::const_iterator i = cs.files_added.begin(); + for (map::const_iterator i = cs.files_added.begin(); i != cs.files_added.end(); ++i) { basic_io::stanza st; @@ -294,7 +294,7 @@ print_cset(basic_io::printer & printer, printer.print_stanza(st); } - for (map >::const_iterator i = cs.deltas_applied.begin(); + for (map >::const_iterator i = cs.deltas_applied.begin(); i != cs.deltas_applied.end(); ++i) { basic_io::stanza st; @@ -304,7 +304,7 @@ print_cset(basic_io::printer & printer, printer.print_stanza(st); } - for (set >::const_iterator i = cs.attrs_cleared.begin(); + for (set >::const_iterator i = cs.attrs_cleared.begin(); i != cs.attrs_cleared.end(); ++i) { basic_io::stanza st; @@ -313,7 +313,7 @@ print_cset(basic_io::printer & printer, printer.print_stanza(st); } - for (map, attr_value>::const_iterator i = cs.attrs_set.begin(); + for (map, attr_value>::const_iterator i = cs.attrs_set.begin(); i != cs.attrs_set.end(); ++i) { basic_io::stanza st; @@ -326,11 +326,11 @@ static inline void static inline void -parse_path(basic_io::parser & parser, split_path & sp) +parse_path(basic_io::parser & parser, file_path & sp) { string s; parser.str(s); - file_path_internal(s).split(sp); + sp = file_path_internal(s); } void @@ -341,23 +341,23 @@ parse_cset(basic_io::parser & parser, string t1, t2; MM(t1); MM(t2); - split_path p1, p2; + file_path p1, p2; MM(p1); MM(p2); - split_path prev_path; + file_path prev_path; MM(prev_path); - pair prev_pair; + pair prev_pair; MM(prev_pair.first); MM(prev_pair.second); - // we make use of the fact that a valid split_path is never empty + // we make use of the fact that a valid file_path is never empty prev_path.clear(); while (parser.symp(syms::delete_node)) { parser.sym(); parse_path(parser, p1); - I(prev_path.empty() || p1 > prev_path); + I(prev_path.empty() || prev_path < p1); prev_path = p1; safe_insert(cs.nodes_deleted, p1); } @@ -367,7 +367,7 @@ parse_cset(basic_io::parser & parser, { parser.sym(); parse_path(parser, p1); - I(prev_path.empty() || p1 > prev_path); + I(prev_path.empty() || prev_path < p1); prev_path = p1; parser.esym(syms::to); parse_path(parser, p2); @@ -379,7 +379,7 @@ parse_cset(basic_io::parser & parser, { parser.sym(); parse_path(parser, p1); - I(prev_path.empty() || p1 > prev_path); + I(prev_path.empty() || prev_path < p1); prev_path = p1; safe_insert(cs.dirs_added, p1); } @@ -389,7 +389,7 @@ parse_cset(basic_io::parser & parser, { parser.sym(); parse_path(parser, p1); - I(prev_path.empty() || p1 > prev_path); + I(prev_path.empty() || prev_path < p1); prev_path = p1; parser.esym(syms::content); parser.hex(t1); @@ -401,7 +401,7 @@ parse_cset(basic_io::parser & parser, { parser.sym(); parse_path(parser, p1); - I(prev_path.empty() || p1 > prev_path); + I(prev_path.empty() || prev_path < p1); prev_path = p1; parser.esym(syms::from); parser.hex(t1); @@ -418,7 +418,7 @@ parse_cset(basic_io::parser & parser, parse_path(parser, p1); parser.esym(syms::attr); parser.str(t1); - pair new_pair(p1, attr_key(t1)); + pair new_pair(p1, attr_key(t1)); I(prev_pair.first.empty() || new_pair > prev_pair); prev_pair = new_pair; safe_insert(cs.attrs_cleared, new_pair); @@ -431,7 +431,7 @@ parse_cset(basic_io::parser & parser, parse_path(parser, p1); parser.esym(syms::attr); parser.str(t1); - pair new_pair(p1, attr_key(t1)); + pair new_pair(p1, attr_key(t1)); I(prev_pair.first.empty() || new_pair > prev_pair); prev_pair = new_pair; parser.esym(syms::value); @@ -691,19 +691,19 @@ UNIT_TEST(cset, cset_written) { L(FL("TEST: cset writing - normalisation")); cset cs; MM(cs); - split_path foo, bar, quux, foo_quux, idle, fish, womble, policeman; file_id f1(string("1234567800000000000000000000000000000000")); file_id f2(string("9876543212394657263900000000000000000000")); file_id f3(string("0000000000011111111000000000000000000000")); - file_path_internal("foo").split(foo); - file_path_internal("foo/quux").split(foo_quux); - file_path_internal("bar").split(bar); - file_path_internal("quux").split(quux); - file_path_internal("idle").split(idle); - file_path_internal("fish").split(fish); - file_path_internal("womble").split(womble); - file_path_internal("policeman").split(policeman); + file_path foo = file_path_internal("foo"); + file_path foo_quux = file_path_internal("foo/quux"); + file_path bar = file_path_internal("bar"); + file_path quux = file_path_internal("quux"); + file_path idle = file_path_internal("idle"); + file_path fish = file_path_internal("fish"); + file_path womble = file_path_internal("womble"); + file_path policeman = file_path_internal("policeman"); + cs.dirs_added.insert(foo_quux); cs.dirs_added.insert(foo); cs.files_added.insert(make_pair(bar, f1)); @@ -766,13 +766,19 @@ UNIT_TEST(cset, basic_csets) file_id f1(string("0000000000000000000000000000000000000001")); file_id f2(string("0000000000000000000000000000000000000002")); - split_path root, foo, foo_bar, baz, quux; - file_path().split(root); - file_path_internal("foo").split(foo); - file_path_internal("foo/bar").split(foo_bar); - file_path_internal("baz").split(baz); - file_path_internal("quux").split(quux); + file_path root; + file_path foo = file_path_internal("foo"); + file_path foo_bar = file_path_internal("foo/bar"); + 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")); @@ -780,8 +786,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(baz))); - UNIT_TEST_CHECK(downcast_to_file_t(r.get_node(baz))->content == f2); + 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(r.all_nodes().size() == 4); } @@ -791,7 +797,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(quux))); + UNIT_TEST_CHECK(is_dir_t(r.get_node(quuxs))); UNIT_TEST_CHECK(r.all_nodes().size() == 4); } @@ -811,9 +817,9 @@ 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(quux))); - UNIT_TEST_CHECK(is_dir_t(r.get_node(foo))); - UNIT_TEST_CHECK(!r.has_node(foo_bar)); + 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(r.all_nodes().size() == 3); } @@ -825,9 +831,9 @@ UNIT_TEST(cset, basic_csets) 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(quux))); + UNIT_TEST_CHECK(is_dir_t(r.get_node(quuxs))); UNIT_TEST_CHECK(is_file_t(r.get_node(quux_bar))); - UNIT_TEST_CHECK(!r.has_node(foo)); + UNIT_TEST_CHECK(!r.has_node(foos)); UNIT_TEST_CHECK(r.all_nodes().size() == 3); } @@ -837,9 +843,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(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(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(r.all_nodes().size() == 3); } @@ -851,10 +857,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_bar))->attrs; + full_attr_map_t attrs = (r.get_node(foo_bars))->attrs; UNIT_TEST_CHECK(attrs[attr_key("ping")] == make_pair(true, attr_value("klang"))); - attrs = (r.get_node(foo))->attrs; + attrs = (r.get_node(foos))->attrs; UNIT_TEST_CHECK(attrs[attr_key("attr_dir")] == make_pair(true, attr_value("value_dir"))); UNIT_TEST_CHECK(r.all_nodes().size() == 3); @@ -868,7 +874,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_bar))->attrs[attr_key("attr_file")] + UNIT_TEST_CHECK((r.get_node(foo_bars))->attrs[attr_key("attr_file")] == make_pair(false, attr_value(""))); UNIT_TEST_CHECK(r.all_nodes().size() == 3); } @@ -877,19 +883,27 @@ UNIT_TEST(cset, basic_csets) { L(FL("TEST: renaming at different levels")); setup_roster(r, f1, nis); - split_path quux_sub, foo_sub, foo_sub_deep, foo_subsub, - foo_subsub_deep, quux_bar, foo_bar, - quux_sub_thing, foo_sub_thing; - file_path_internal("quux/bar").split(quux_bar); - file_path_internal("foo/bar").split(foo_bar); - file_path_internal("quux/sub").split(quux_sub); - file_path_internal("foo/sub").split(foo_sub); - file_path_internal("foo/sub/thing").split(foo_sub_thing); - file_path_internal("quux/sub/thing").split(quux_sub_thing); - file_path_internal("foo/sub/deep").split(foo_sub_deep); - file_path_internal("foo/subsub").split(foo_subsub); - file_path_internal("foo/subsub/deep").split(foo_subsub_deep); + file_path quux_bar = file_path_internal("quux/bar"); + file_path foo_bar = file_path_internal("foo/bar"); + file_path quux_sub = file_path_internal("quux/sub"); + file_path foo_sub = file_path_internal("foo/sub"); + file_path foo_sub_thing = file_path_internal("foo/sub/thing"); + file_path quux_sub_thing = file_path_internal("quux/sub/thing"); + file_path foo_sub_deep = file_path_internal("foo/sub/deep"); + 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); @@ -911,16 +925,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_bar))); - UNIT_TEST_CHECK(!(r.has_node(foo_bar))); + UNIT_TEST_CHECK(is_file_t(r.get_node(quux_bars))); + UNIT_TEST_CHECK(!(r.has_node(foo_bars))); // /foo/sub/deep -> /foo/subsub/deep - UNIT_TEST_CHECK(is_file_t(r.get_node(foo_subsub_deep))); - UNIT_TEST_CHECK(!(r.has_node(foo_sub_deep))); + UNIT_TEST_CHECK(is_file_t(r.get_node(foo_subsub_deeps))); + UNIT_TEST_CHECK(!(r.has_node(foo_sub_deeps))); // /quux/sub -> /foo/sub - UNIT_TEST_CHECK(is_dir_t(r.get_node(foo_sub))); - UNIT_TEST_CHECK(!(r.has_node(quux_sub))); + UNIT_TEST_CHECK(is_dir_t(r.get_node(foo_subs))); + UNIT_TEST_CHECK(!(r.has_node(quux_subs))); // /quux/sub/thing -> /foo/sub/thing - UNIT_TEST_CHECK(is_file_t(r.get_node(foo_sub_thing))); + UNIT_TEST_CHECK(is_file_t(r.get_node(foo_sub_things))); } { @@ -931,7 +945,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(foo))); + UNIT_TEST_CHECK(is_file_t(r.get_node(foos))); } } @@ -945,12 +959,11 @@ UNIT_TEST(cset, invalid_csets) file_id f1(string("0000000000000000000000000000000000000001")); file_id f2(string("0000000000000000000000000000000000000002")); - split_path root, foo, foo_bar, baz, quux; - file_path().split(root); - file_path_internal("foo").split(foo); - file_path_internal("foo/bar").split(foo_bar); - file_path_internal("baz").split(baz); - file_path_internal("quux").split(quux); + file_path root; + file_path foo = file_path_internal("foo"); + file_path foo_bar = file_path_internal("foo/bar"); + file_path baz = file_path_internal("baz"); + file_path quux = file_path_internal("quux"); { L(FL("TEST: can't double-delete")); @@ -1016,8 +1029,7 @@ UNIT_TEST(cset, invalid_csets) L(FL("TEST: can't rename 'a' 'b'; rename 'a/foo' 'b/foo'")); setup_roster(r, f1, nis); cset cs; MM(cs); - split_path baz_bar; - file_path_internal("baz/bar").split(baz_bar); + file_path baz_bar = file_path_internal("baz/bar"); cs.nodes_renamed.insert(make_pair(foo, baz)); cs.nodes_renamed.insert(make_pair(foo_bar, baz_bar)); UNIT_TEST_CHECK_THROW(cs.apply_to(tree), logic_error); @@ -1093,8 +1105,7 @@ UNIT_TEST(cset, invalid_csets) // for this test, make sure original roster has no contents r = roster_t(); cset cs; MM(cs); - split_path sp; - file_path_internal("blah/blah/blah").split(sp); + file_path sp = file_path_internal("blah/blah/blah"); cs.dirs_added.insert(sp); UNIT_TEST_CHECK_THROW(cs.apply_to(tree), logic_error); } @@ -1102,8 +1113,7 @@ UNIT_TEST(cset, invalid_csets) L(FL("TEST: can't move a directory underneath itself")); setup_roster(r, f1, nis); cset cs; MM(cs); - split_path foo_blah; - file_path_internal("foo/blah").split(foo_blah); + file_path foo_blah = file_path_internal("foo/blah"); cs.nodes_renamed.insert(make_pair(foo, foo_blah)); UNIT_TEST_CHECK_THROW(cs.apply_to(tree), logic_error); } @@ -1118,15 +1128,14 @@ UNIT_TEST(cset, root_dir) file_id f1(string("0000000000000000000000000000000000000001")); - split_path root, baz; - file_path().split(root); - file_path_internal("baz").split(baz); + file_path root, baz = file_path_internal("baz"); + split_path roots; root.split(roots); { L(FL("TEST: can rename root")); setup_roster(r, f1, nis); cset cs; MM(cs); - split_path sp1, sp2; + file_path sp1, sp2; cs.dirs_added.insert(root); cs.nodes_renamed.insert(make_pair(root, baz)); cs.apply_to(tree); @@ -1136,7 +1145,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), root); + r.attach_node(r.create_dir_node(nis), roots); cset cs; MM(cs); cs.nodes_deleted.insert(root); cs.apply_to(tree); @@ -1145,7 +1154,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), root); + r.attach_node(r.create_dir_node(nis), roots); cset cs; MM(cs); cs.nodes_deleted.insert(root); cs.dirs_added.insert(root); ============================================================ --- cset.hh eedb0328724138427340bbd88a8ebc48f2f29273 +++ cset.hh f395ff8f90e463ab9744db5a1946f23f78034c23 @@ -31,21 +31,21 @@ struct editable_tree struct editable_tree { // Detaching existing nodes (for renaming or deleting) - virtual node_id detach_node(split_path const & src) = 0; + virtual node_id detach_node(file_path const & src) = 0; virtual void drop_detached_node(node_id nid) = 0; // Attaching new nodes (via creation or as the tail end of renaming) virtual node_id create_dir_node() = 0; virtual node_id create_file_node(file_id const & content) = 0; - virtual void attach_node(node_id nid, split_path const & dst) = 0; + virtual void attach_node(node_id nid, file_path const & dst) = 0; // Modifying elements in-place - virtual void apply_delta(split_path const & pth, + virtual void apply_delta(file_path const & pth, file_id const & old_id, file_id const & new_id) = 0; - virtual void clear_attr(split_path const & pth, + virtual void clear_attr(file_path const & pth, attr_key const & name) = 0; - virtual void set_attr(split_path const & pth, + virtual void set_attr(file_path const & pth, attr_key const & name, attr_value const & val) = 0; @@ -60,21 +60,21 @@ struct cset struct cset { // Deletions. - path_set nodes_deleted; + std::set nodes_deleted; // Additions. - path_set dirs_added; - std::map files_added; + std::set dirs_added; + std::map files_added; // Pure renames. - std::map nodes_renamed; + std::map nodes_renamed; // Pure deltas. - std::map > deltas_applied; + std::map > deltas_applied; // Attribute changes. - std::set > attrs_cleared; - std::map, attr_value> attrs_set; + std::set > attrs_cleared; + std::map, attr_value> attrs_set; bool operator==(cset const & other) const { @@ -93,20 +93,20 @@ struct cset void clear(); }; -inline split_path const & -delta_entry_path(std::map >::const_iterator i) +inline file_path const & +delta_entry_path(std::map >::const_iterator i) { return i->first; } inline file_id const & -delta_entry_src(std::map >::const_iterator i) +delta_entry_src(std::map >::const_iterator i) { return i->second.first; } inline file_id const & -delta_entry_dst(std::map >::const_iterator i) +delta_entry_dst(std::map >::const_iterator i) { return i->second.second; } ============================================================ --- database.cc 8fc87fee1363699af5621f703b85ae288b499491 +++ database.cc 00303a4bcbf958f20bf32f244fa8d7997a54d749 @@ -1953,7 +1953,7 @@ database::deltify_revision(revision_id c for (edge_map::const_iterator i = rev.edges.begin(); i != rev.edges.end(); ++i) { - for (map >::const_iterator + for (map >::const_iterator j = edge_changes(i).deltas_applied.begin(); j != edge_changes(i).deltas_applied.end(); ++j) { @@ -2009,7 +2009,7 @@ database::put_revision(revision_id const return false; } - for (map::const_iterator a + for (map::const_iterator a = edge_changes(i).files_added.begin(); a != edge_changes(i).files_added.end(); ++a) { @@ -2021,7 +2021,7 @@ database::put_revision(revision_id const } } - for (map >::const_iterator d + for (map >::const_iterator d = edge_changes(i).deltas_applied.begin(); d != edge_changes(i).deltas_applied.end(); ++d) { ============================================================ --- enumerator.cc eec6cead8d287bcb00376bb9f2ed8a48fad7f229 +++ enumerator.cc 103045a099579dcbbe7d7044798946522f8b0c91 @@ -126,7 +126,7 @@ revision_enumerator::files_for_revision( cset const & cs = edge_changes(i); // Queue up all the file-adds - for (map::const_iterator fa = cs.files_added.begin(); + for (map::const_iterator fa = cs.files_added.begin(); fa != cs.files_added.end(); ++fa) { file_adds.insert(fa->second); @@ -134,7 +134,7 @@ revision_enumerator::files_for_revision( } // Queue up all the file-deltas - for (map >::const_iterator fd + for (map >::const_iterator fd = cs.deltas_applied.begin(); fd != cs.deltas_applied.end(); ++fd) { ============================================================ --- paths.cc ffbea7c9012969491367d66bbd26d8da87860734 +++ paths.cc 51e6ebc6e9079807485d8359c8e17726ed74619c @@ -461,17 +461,31 @@ void dump(split_path const & sp, string void dump(split_path const & sp, string & out) { ostringstream oss; + oss << sp << '\n'; + out = oss.str(); +} - for (split_path::const_iterator i = sp.begin(); i != sp.end(); ++i) - { - if (null_name(*i)) - oss << '.'; - else - oss << '/' << *i; - } +template <> +void dump(file_path const & p, string & out) +{ + ostringstream oss; + oss << p << '\n'; + out = oss.str(); +} - oss << '\n'; +template <> +void dump(system_path const & p, string & out) +{ + ostringstream oss; + oss << p << '\n'; + out = oss.str(); +} +template <> +void dump(bookkeeping_path const & p, string & out) +{ + ostringstream oss; + oss << p << '\n'; out = oss.str(); } ============================================================ --- paths.hh 95e2d4782ab7e04859e292f8b92aad4ead046b83 +++ paths.hh 3c3ad14d890d72a47e359d698e687520d594c13c @@ -123,8 +123,6 @@ workspace_root(split_path const & sp); bool workspace_root(split_path const & sp); -template <> void dump(split_path const & sp, std::string & out); - // It's possible this will become a proper virtual interface in the future, // but since the implementation is exactly the same in all cases, there isn't // much point ATM... @@ -151,6 +149,8 @@ std::ostream & operator<<(std::ostream & std::ostream & operator<<(std::ostream & o, any_path const & a); std::ostream & operator<<(std::ostream & o, split_path const & s); +template <> void dump(split_path const & sp, std::string & out); + class file_path : public any_path { public: @@ -169,6 +169,8 @@ public: bool operator <(const file_path & other) const { return data < other.data; } + void clear() { data = utf8(); } + private: typedef enum { internal, external } source_type; // input is always in utf8, because everything in our world is always in @@ -246,6 +248,12 @@ public: system_path operator /(std::string const & to_append) const; }; +template <> void dump(file_path const & sp, std::string & out); +template <> void dump(bookkeeping_path const & sp, std::string & out); +template <> void dump(system_path const & sp, std::string & out); + +// utilities + void dirname_basename(split_path const & sp, split_path & dirname, path_component & basename); ============================================================ --- roster.cc 2d66e04b7ca82b71b11f9aa3d8263ff0a193c013 +++ roster.cc 84e18891eff147958ea6547f9d26d7679afa3cc0 @@ -1072,10 +1072,12 @@ node_id {} node_id -editable_roster_base::detach_node(split_path const & src) +editable_roster_base::detach_node(file_path const & src) { // L(FL("detach_node('%s')") % file_path(src)); - return r.detach_node(src); + split_path sp; + src.split(sp); + return r.detach_node(sp); } void @@ -1104,38 +1106,46 @@ void } void -editable_roster_base::attach_node(node_id nid, split_path const & dst) +editable_roster_base::attach_node(node_id nid, file_path const & dst) { // L(FL("attach_node(%d, '%s')") % nid % file_path(dst)); MM(dst); MM(this->r); - r.attach_node(nid, dst); + split_path sd; + dst.split(sd); + r.attach_node(nid, sd); } void -editable_roster_base::apply_delta(split_path const & pth, +editable_roster_base::apply_delta(file_path const & pth, file_id const & old_id, file_id const & new_id) { - // L(FL("clear_attr('%s', '%s', '%s')") % file_path(pth) % old_id % new_id); - r.apply_delta(pth, old_id, new_id); + // L(FL("apply_delta('%s', '%s', '%s')") % file_path(pth) % old_id % new_id); + split_path sp; + pth.split(sp); + r.apply_delta(sp, old_id, new_id); } void -editable_roster_base::clear_attr(split_path const & pth, +editable_roster_base::clear_attr(file_path const & pth, attr_key const & name) { // L(FL("clear_attr('%s', '%s')") % file_path(pth) % name); - r.clear_attr(pth, name); + split_path sp; + pth.split(sp); + r.clear_attr(sp, name); } void -editable_roster_base::set_attr(split_path const & pth, +editable_roster_base::set_attr(file_path const & pth, attr_key const & name, attr_value const & val) { // L(FL("set_attr('%s', '%s', '%s')") % file_path(pth) % name % val); - r.set_attr(pth, name, val); + split_path sp; + pth.split(sp); + r.set_attr(sp, name, val); } void @@ -1662,7 +1672,7 @@ namespace { rid(rid), markings(markings) {} - virtual node_id detach_node(split_path const & src) + virtual node_id detach_node(file_path const & src) { node_id nid = this->editable_roster_base::detach_node(src); marking_map::iterator marking = markings.find(nid); @@ -1688,24 +1698,26 @@ namespace { return handle_new(this->editable_roster_base::create_file_node(content)); } - virtual void apply_delta(split_path const & pth, + virtual void apply_delta(file_path const & pth, file_id const & old_id, file_id const & new_id) { this->editable_roster_base::apply_delta(pth, old_id, new_id); - node_id nid = r.get_node(pth)->self; + split_path sp; + pth.split(sp); + node_id nid = r.get_node(sp)->self; marking_map::iterator marking = markings.find(nid); I(marking != markings.end()); marking->second.file_content.clear(); marking->second.file_content.insert(rid); } - virtual void clear_attr(split_path const & pth, attr_key const & name) + virtual void clear_attr(file_path const & pth, attr_key const & name) { this->editable_roster_base::clear_attr(pth, name); handle_attr(pth, name); } - virtual void set_attr(split_path const & pth, attr_key const & name, + virtual void set_attr(file_path const & pth, attr_key const & name, attr_value const & val) { this->editable_roster_base::set_attr(pth, name, val); @@ -1721,9 +1733,11 @@ namespace { return nid; } - void handle_attr(split_path const & pth, attr_key const & name) + void handle_attr(file_path const & pth, attr_key const & name) { - node_id nid = r.get_node(pth)->self; + split_path sp; + pth.split(sp); + node_id nid = r.get_node(sp)->self; marking_map::iterator marking = markings.find(nid); map >::iterator am = marking->second.attrs.find(name); if (am == marking->second.attrs.end()) @@ -2215,9 +2229,9 @@ class editable_roster_for_check { public: editable_roster_for_check(roster_t & r); - virtual node_id detach_node(split_path const & src); + virtual node_id detach_node(file_path const & src); virtual void drop_detached_node(node_id nid); - virtual void attach_node(node_id nid, split_path const & dst); + virtual void attach_node(node_id nid, file_path const & dst); int problems; private: @@ -2248,9 +2262,11 @@ node_id } node_id -editable_roster_for_check::detach_node(split_path const & src) +editable_roster_for_check::detach_node(file_path const & src) { - node_t n = r.get_node(src); + split_path sp; + src.split(sp); + node_t n = r.get_node(sp); if (is_dir_t(n)) { dir_t dir = downcast_to_dir_t(n); @@ -2261,7 +2277,7 @@ editable_roster_for_check::detach_node(s children.push_back(i->first); } detached_dirs.insert(make_pair(dir->self, - make_pair(src, children))); + make_pair(sp, children))); } return this->editable_roster_base::detach_node(src); @@ -2295,11 +2311,13 @@ void } void -editable_roster_for_check::attach_node(node_id nid, split_path const & dst) +editable_roster_for_check::attach_node(node_id nid, file_path const & dst) { + split_path sd; + dst.split(sd); split_path dirname; path_component basename; - dirname_basename(dst, dirname, basename); + dirname_basename(sd, dirname, basename); if (!dirname.empty() && !r.has_node(dirname)) { @@ -2343,15 +2361,15 @@ select_nodes_modified_by_cset(cset const { nodes_modified.clear(); - path_set modified_prestate_nodes; - path_set modified_poststate_nodes; + set modified_prestate_nodes; + set modified_poststate_nodes; // Pre-state damage copy(cs.nodes_deleted.begin(), cs.nodes_deleted.end(), inserter(modified_prestate_nodes, modified_prestate_nodes.begin())); - for (map::const_iterator i = cs.nodes_renamed.begin(); + for (map::const_iterator i = cs.nodes_renamed.begin(); i != cs.nodes_renamed.end(); ++i) modified_prestate_nodes.insert(i->first); @@ -2360,40 +2378,44 @@ select_nodes_modified_by_cset(cset const copy(cs.dirs_added.begin(), cs.dirs_added.end(), inserter(modified_poststate_nodes, modified_poststate_nodes.begin())); - for (map::const_iterator i = cs.files_added.begin(); + for (map::const_iterator i = cs.files_added.begin(); i != cs.files_added.end(); ++i) modified_poststate_nodes.insert(i->first); - for (map::const_iterator i = cs.nodes_renamed.begin(); + for (map::const_iterator i = cs.nodes_renamed.begin(); i != cs.nodes_renamed.end(); ++i) modified_poststate_nodes.insert(i->second); - for (map >::const_iterator i = cs.deltas_applied.begin(); + for (map >::const_iterator i = cs.deltas_applied.begin(); i != cs.deltas_applied.end(); ++i) modified_poststate_nodes.insert(i->first); - for (set >::const_iterator i = cs.attrs_cleared.begin(); + for (set >::const_iterator i = cs.attrs_cleared.begin(); i != cs.attrs_cleared.end(); ++i) modified_poststate_nodes.insert(i->first); - for (map, attr_value>::const_iterator i = cs.attrs_set.begin(); + for (map, attr_value>::const_iterator i = cs.attrs_set.begin(); i != cs.attrs_set.end(); ++i) modified_poststate_nodes.insert(i->first.first); // Finale - for (path_set::const_iterator i = modified_prestate_nodes.begin(); + for (set::const_iterator i = modified_prestate_nodes.begin(); i != modified_prestate_nodes.end(); ++i) { - I(old_roster.has_node(*i)); - nodes_modified.insert(old_roster.get_node(*i)->self); + split_path s; + i->split(s); + I(old_roster.has_node(s)); + nodes_modified.insert(old_roster.get_node(s)->self); } - for (path_set::const_iterator i = modified_poststate_nodes.begin(); + for (set::const_iterator i = modified_poststate_nodes.begin(); i != modified_poststate_nodes.end(); ++i) { - I(new_roster.has_node(*i)); - nodes_modified.insert(new_roster.get_node(*i)->self); + split_path s; + i->split(s); + I(new_roster.has_node(s)); + nodes_modified.insert(new_roster.get_node(s)->self); } } ============================================================ --- roster.hh 58f56b5761388f0c4a35436532a64b6c7812b755 +++ roster.hh 2c54cc36a5c5c34be76013593921b451513a33a8 @@ -327,17 +327,17 @@ public: { public: editable_roster_base(roster_t & r, node_id_source & nis); - virtual node_id detach_node(split_path const & src); + virtual node_id detach_node(file_path const & src); virtual void drop_detached_node(node_id nid); virtual node_id create_dir_node(); virtual node_id create_file_node(file_id const & content); - virtual void attach_node(node_id nid, split_path const & dst); - virtual void apply_delta(split_path const & pth, + virtual void attach_node(node_id nid, file_path const & dst); + virtual void apply_delta(file_path const & pth, file_id const & old_id, file_id const & new_id); - virtual void clear_attr(split_path const & pth, + virtual void clear_attr(file_path const & pth, attr_key const & name); - virtual void set_attr(split_path const & pth, + virtual void set_attr(file_path const & pth, attr_key const & name, attr_value const & val); virtual void commit(); ============================================================ --- work.cc 66159e9dae0264bfc4b066b87f8cf6888900cfb5 +++ work.cc ba49d44159b566894eafbc7db222b1716505dbb2 @@ -664,19 +664,19 @@ struct editable_working_tree : public ed messages(messages) {}; - virtual node_id detach_node(split_path const & src); + virtual node_id detach_node(file_path const & src); virtual void drop_detached_node(node_id nid); virtual node_id create_dir_node(); virtual node_id create_file_node(file_id const & content); - virtual void attach_node(node_id nid, split_path const & dst); + virtual void attach_node(node_id nid, file_path const & dst); - virtual void apply_delta(split_path const & pth, + virtual void apply_delta(file_path const & pth, file_id const & old_id, file_id const & new_id); - virtual void clear_attr(split_path const & pth, + virtual void clear_attr(file_path const & pth, attr_key const & name); - virtual void set_attr(split_path const & pth, + virtual void set_attr(file_path const & pth, attr_key const & name, attr_value const & val); @@ -698,26 +698,26 @@ struct simulated_working_tree : public e roster_t & workspace; node_id_source & nis; - path_set blocked_paths; - map nid_map; + set blocked_paths; + map nid_map; int conflicts; simulated_working_tree(roster_t & r, temp_node_id_source & n) : workspace(r), nis(n), conflicts(0) {} - virtual node_id detach_node(split_path const & src); + virtual node_id detach_node(file_path const & src); virtual void drop_detached_node(node_id nid); virtual node_id create_dir_node(); virtual node_id create_file_node(file_id const & content); - virtual void attach_node(node_id nid, split_path const & dst); + virtual void attach_node(node_id nid, file_path const & dst); - virtual void apply_delta(split_path const & pth, + virtual void apply_delta(file_path const & pth, file_id const & old_id, file_id const & new_id); - virtual void clear_attr(split_path const & pth, + virtual void clear_attr(file_path const & pth, attr_key const & name); - virtual void set_attr(split_path const & pth, + virtual void set_attr(file_path const & pth, attr_key const & name, attr_value const & val); @@ -773,11 +773,10 @@ node_id // parent. node_id -editable_working_tree::detach_node(split_path const & src) +editable_working_tree::detach_node(file_path const & src_pth) { I(root_dir_attached); node_id nid = next_nid++; - file_path src_pth(src); bookkeeping_path dst_pth = path_for_detached_nid(nid); safe_insert(rename_add_drop_map, make_pair(dst_pth, src_pth)); if (src_pth == file_path()) @@ -836,10 +835,9 @@ void } void -editable_working_tree::attach_node(node_id nid, split_path const & dst) +editable_working_tree::attach_node(node_id nid, file_path const & dst_pth) { bookkeeping_path src_pth = path_for_detached_nid(nid); - file_path dst_pth(dst); map::const_iterator i = rename_add_drop_map.find(src_pth); @@ -876,35 +874,34 @@ void } void -editable_working_tree::apply_delta(split_path const & pth, +editable_working_tree::apply_delta(file_path const & pth, file_id const & old_id, file_id const & new_id) { - file_path pth_unsplit(pth); - require_path_is_file(pth_unsplit, - F("file '%s' does not exist") % pth_unsplit, - F("file '%s' is a directory") % pth_unsplit); + require_path_is_file(pth, + F("file '%s' does not exist") % pth, + F("file '%s' is a directory") % pth); hexenc curr_id_raw; - calculate_ident(pth_unsplit, curr_id_raw); + calculate_ident(pth, curr_id_raw); file_id curr_id(curr_id_raw); E(curr_id == old_id, - F("content of file '%s' has changed, not overwriting") % pth_unsplit); - P(F("modifying %s") % pth_unsplit); + F("content of file '%s' has changed, not overwriting") % pth); + P(F("modifying %s") % pth); file_data dat; source.get_version(new_id, dat); - write_data(pth_unsplit, dat.inner()); + write_data(pth, dat.inner()); } void -editable_working_tree::clear_attr(split_path const & pth, +editable_working_tree::clear_attr(file_path const & pth, attr_key const & name) { // FIXME_ROSTERS: call a lua hook } void -editable_working_tree::set_attr(split_path const & pth, +editable_working_tree::set_attr(file_path const & pth, attr_key const & name, attr_value const & val) { @@ -924,9 +921,11 @@ node_id node_id -simulated_working_tree::detach_node(split_path const & src) +simulated_working_tree::detach_node(file_path const & src) { - node_id nid = workspace.detach_node(src); + split_path sp; + src.split(sp); + node_id nid = workspace.detach_node(sp); nid_map.insert(make_pair(nid, src)); return nid; } @@ -940,10 +939,9 @@ simulated_working_tree::drop_detached_no dir_t dir = downcast_to_dir_t(node); if (!dir->children.empty()) { - map::const_iterator i = nid_map.find(nid); + map::const_iterator i = nid_map.find(nid); I(i != nid_map.end()); - split_path path = i->second; - W(F("cannot drop non-empty directory '%s'") % path); + W(F("cannot drop non-empty directory '%s'") % i->second); conflicts++; } } @@ -962,40 +960,42 @@ void } void -simulated_working_tree::attach_node(node_id nid, split_path const & dst) +simulated_working_tree::attach_node(node_id nid, file_path const & dst) { // this check is needed for checkout because we're using a roster to // 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(dst) && workspace.has_root()) + if (workspace_root(dsts) && workspace.has_root()) return; - if (workspace.has_node(dst)) + if (workspace.has_node(dsts)) { W(F("attach node %d blocked by unversioned path '%s'") % nid % dst); - blocked_paths.insert(dst); + blocked_paths.insert(dsts); conflicts++; } else { split_path dirname; path_component basename; - dirname_basename(dst, dirname, basename); + dirname_basename(dsts, dirname, basename); if (blocked_paths.find(dirname) == blocked_paths.end()) - workspace.attach_node(nid, dst); + workspace.attach_node(nid, dsts); else { W(F("attach node %d blocked by blocked parent '%s'") % nid % dst); - blocked_paths.insert(dst); + blocked_paths.insert(dsts); } } } void -simulated_working_tree::apply_delta(split_path const & path, +simulated_working_tree::apply_delta(file_path const & path, file_id const & old_id, file_id const & new_id) { @@ -1004,13 +1004,13 @@ void } void -simulated_working_tree::clear_attr(split_path const & pth, +simulated_working_tree::clear_attr(file_path const & pth, attr_key const & name) { } void -simulated_working_tree::set_attr(split_path const & pth, +simulated_working_tree::set_attr(file_path const & pth, attr_key const & name, attr_value const & val) {