# # # patch "legacy.cc" # from [6867f219f457fa5df90b2801871c1e1f61a451f0] # to [407ccc4a6e0da19947da83e4e6d3e56edc39d05b] # # patch "legacy.hh" # from [158f7db6cbe333fe695d3a8dcd335ad0abc47e7d] # to [3ff3222605c18fd4711ecd40e310e0a0f7625941] # # patch "revision.cc" # from [c104bebaafde9e2db6ae34d8934aefd29b89a4ed] # to [7211ea4e920a4f357b445b99c8f7713ae559d422] # ============================================================ --- legacy.cc 6867f219f457fa5df90b2801871c1e1f61a451f0 +++ legacy.cc 407ccc4a6e0da19947da83e4e6d3e56edc39d05b @@ -102,10 +102,8 @@ namespace legacy parser.str(from_str); parser.esym(syms::to); parser.str(to_str); - split_path from, to; - file_path_internal(from_str).split(from); - file_path_internal(to_str).split(to); - renames[old_rev][to] = from; + renames[old_rev][file_path_internal(to_str)] + = file_path_internal(from_str); } else if (parser.symp(syms::patch)) { ============================================================ --- legacy.hh 158f7db6cbe333fe695d3a8dcd335ad0abc47e7d +++ legacy.hh 3ff3222605c18fd4711ecd40e310e0a0f7625941 @@ -38,7 +38,7 @@ namespace legacy // *partially* read them, however, in order to get the manifest IDs out of // the old revisions (before we delete the revs and rebuild them) - typedef std::map > renames_map; + typedef std::map > renames_map; void get_manifest_and_renames_for_rev(app_state & app, ============================================================ --- revision.cc c104bebaafde9e2db6ae34d8934aefd29b89a4ed +++ revision.cc 7211ea4e920a4f357b445b99c8f7713ae559d422 @@ -1170,35 +1170,29 @@ not_dead_yet(node_id nid, u64 birth_rev, } -static split_path -find_old_path_for(map const & renames, - split_path const & new_path) +static file_path +find_old_path_for(map const & renames, + file_path const & new_path) { - split_path leader, trailer; - leader = new_path; - while (!leader.empty()) - { - if (renames.find(leader) != renames.end()) - { - leader = safe_get(renames, leader); - break; - } - path_component pc = leader.back(); - leader.pop_back(); - trailer.insert(trailer.begin(), pc); - } - split_path result; - copy(leader.begin(), leader.end(), back_inserter(result)); - copy(trailer.begin(), trailer.end(), back_inserter(result)); - return result; + map::const_iterator i = renames.find(new_path); + if (i != renames.end()) + return i->second; + + // ??? root directory rename possible in the old schema? + // if not, do this first. + if (new_path.empty()) + return new_path; + + return (find_old_path_for(renames, new_path.dirname()) + / new_path.basename()()); } -static split_path -find_new_path_for(map const & renames, - split_path const & old_path) +static file_path +find_new_path_for(map const & renames, + file_path const & old_path) { - map reversed; - for (map::const_iterator i = renames.begin(); + map reversed; + for (map::const_iterator i = renames.begin(); i != renames.end(); ++i) reversed.insert(make_pair(i->second, i->first)); // this is a hackish kluge. seems to work, though. @@ -1313,8 +1307,6 @@ anc_graph::fixup_node_identities(parent_ file_path fp; parent_roster->get_name(n, fp); - split_path sp; - fp.split(sp); // Try remapping the name. if (node_to_old_rev.find(j->first) != node_to_old_rev.end()) @@ -1323,15 +1315,15 @@ anc_graph::fixup_node_identities(parent_ revision_id parent_rid = safe_get(node_to_old_rev, j->first); rmap = renames.find(parent_rid); if (rmap != renames.end()) - sp = find_new_path_for(rmap->second, sp); + fp = find_new_path_for(rmap->second, fp); } // See if we can match this node against a child. if ((!child_roster.has_node(n)) - && child_roster.has_node(file_path(sp))) + && child_roster.has_node(fp)) { node_t pn = parent_roster->get_node(n); - node_t cn = child_roster.get_node(file_path(sp)); + node_t cn = child_roster.get_node(fp); if (is_file_t(pn) == is_file_t(cn)) { child_roster.replace_node_id(cn->self, n); @@ -1940,13 +1932,12 @@ UNIT_TEST(revision, find_old_new_path_fo UNIT_TEST(revision, find_old_new_path_for) { - map renames; - split_path foo, foo_bar, foo_baz, quux, quux_baz; - file_path_internal("foo").split(foo); - file_path_internal("foo/bar").split(foo_bar); - file_path_internal("foo/baz").split(foo_baz); - file_path_internal("quux").split(quux); - file_path_internal("quux/baz").split(quux_baz); + map renames; + file_path foo = file_path_internal("foo"); + file_path foo_bar = file_path_internal("foo/bar"); + file_path foo_baz = file_path_internal("foo/baz"); + file_path quux = file_path_internal("quux"); + file_path quux_baz = file_path_internal("quux/baz"); I(foo == find_old_path_for(renames, foo)); I(foo == find_new_path_for(renames, foo)); I(foo_bar == find_old_path_for(renames, foo_bar));