# # # patch "cmd_merging.cc" # from [7eaf99bb864a567857360e9aee6b1417ef8138aa] # to [e7d15cb2e930e5b9f1c7ea814f07eebd6968f6d9] # # patch "paths.cc" # from [cde7cef55a0561ee5b62e11c3ef6ddcfc7c27941] # to [7b8b7517f11ee0d21ceab98dc7c674ab0d1a8e39] # # patch "paths.hh" # from [e3dcd5e03c1de9c53b22efa737daf70d9ed18d3b] # to [62d574a1d6034240303fab1d453c0a786e52d996] # # patch "restrictions.cc" # from [bb42700e6be89ba8456eb237e708343f1cd074f1] # to [1cfe70b83bb6fc1cc0c3291dee38ba94e0d03de0] # # patch "revision.cc" # from [d82508920e55c80c57b00d22d651a495d3c0b491] # to [c104bebaafde9e2db6ae34d8934aefd29b89a4ed] # # patch "roster.cc" # from [e88d4bee4877895f715544a61e5f6db48ee1ff18] # to [ff1087ea2aba58f6063ac2ae70adef654b9f7f82] # # patch "roster.hh" # from [b7db1764e51b0a45e81539e1b7dc761c472b344a] # to [99d0e9db42ece21e45383b0dc8cef0ddb525f77c] # # patch "work.cc" # from [0a620927cb7acea3ae46fb0cb5948e36cdbe9c6f] # to [0feedb585ed60dbc8cb3f204a925e094255c5c9d] # ============================================================ --- cmd_merging.cc 7eaf99bb864a567857360e9aee6b1417ef8138aa +++ cmd_merging.cc e7d15cb2e930e5b9f1c7ea814f07eebd6968f6d9 @@ -535,28 +535,26 @@ CMD(merge_into_dir, "merge_into_dir", "" left_uncommon_ancestors, right_uncommon_ancestors); - { - dir_t moved_root = left_roster.root(); - split_path sp, dirname; - path_component basename; - MM(dirname); - if (!idx(args,2)().empty()) - { - file_path_external(idx(args,2)).split(sp); - dirname_basename(sp, dirname, basename); - N(right_roster.has_node(file_path(dirname)), - F("Path %s not found in destination tree.") % sp); - node_t parent = right_roster.get_node(file_path(dirname)); - moved_root->parent = parent->self; - moved_root->name = basename; - marking_map::iterator - i = left_marking_map.find(moved_root->self); - I(i != left_marking_map.end()); - i->second.parent_name.clear(); - i->second.parent_name.insert(left_rid); - } - } + if (!idx(args,2)().empty()) + { + dir_t moved_root = left_roster.root(); + file_path pth = file_path_external(idx(args, 2)); + file_path dir = pth.dirname(); + path_component base = pth.basename(); + MM(dir); + N(right_roster.has_node(dir), + F("Path %s not found in destination tree.") % pth); + node_t parent = right_roster.get_node(dir); + moved_root->parent = parent->self; + moved_root->name = base; + marking_map::iterator + i = left_marking_map.find(moved_root->self); + I(i != left_marking_map.end()); + i->second.parent_name.clear(); + i->second.parent_name.insert(left_rid); + } + roster_merge_result result; roster_merge(left_roster, left_marking_map, ============================================================ --- paths.cc cde7cef55a0561ee5b62e11c3ef6ddcfc7c27941 +++ paths.cc 7b8b7517f11ee0d21ceab98dc7c674ab0d1a8e39 @@ -651,32 +651,6 @@ system_path::system_path(utf8 const & pa } /////////////////////////////////////////////////////////////////////////// -// utility -/////////////////////////////////////////////////////////////////////////// - -bool -workspace_root(file_path const & path) -{ - return path.empty(); -} - -void -dirname_basename(split_path const & sp, - split_path & dirname, path_component & basename) -{ - I(!sp.empty()); - // L(FL("dirname_basename('%s' [%d components],...)") % file_path(sp) % sp.size()); - dirname = sp; - dirname.pop_back(); - basename = sp.back(); - if (dirname.empty()) - { - // L(FL("basename %d vs. null component %d") % basename % the_null_component); - I(null_name(basename)); - } -} - -/////////////////////////////////////////////////////////////////////////// // workspace (and path root) handling /////////////////////////////////////////////////////////////////////////// ============================================================ --- paths.hh e3dcd5e03c1de9c53b22efa737daf70d9ed18d3b +++ paths.hh 62d574a1d6034240303fab1d453c0a786e52d996 @@ -279,16 +279,8 @@ template <> void dump(system_path const template <> void dump(bookkeeping_path const & sp, std::string & out); template <> void dump(system_path const & sp, std::string & out); -// utilities - -bool -workspace_root(file_path const & path); - +// record the initial path. must be called before any use of system_path. void -dirname_basename(split_path const & sp, - split_path & dirname, path_component & basename); - -void save_initial_path(); // returns true if workspace found, in which case cwd has been changed ============================================================ --- restrictions.cc bb42700e6be89ba8456eb237e708343f1cd074f1 +++ restrictions.cc 1cfe70b83bb6fc1cc0c3291dee38ba94e0d03de0 @@ -118,7 +118,7 @@ validate_workspace_paths(set for (set::const_iterator i = included_paths.begin(); i != included_paths.end(); ++i) { - if (workspace_root(*i)) + if (i->empty()) continue; // ignored paths are allowed into the restriction but are not @@ -134,7 +134,7 @@ validate_workspace_paths(set for (set::const_iterator i = excluded_paths.begin(); i != excluded_paths.end(); ++i) { - if (workspace_root(*i)) + if (i->empty()) continue; if (!path_exists(*i)) ============================================================ --- revision.cc d82508920e55c80c57b00d22d651a495d3c0b491 +++ revision.cc c104bebaafde9e2db6ae34d8934aefd29b89a4ed @@ -1205,7 +1205,28 @@ find_new_path_for(mapchildren.find(p.basename()); + if (child == pd->children.end()) + return node_t(); + + return child->second; +} + node_t roster_t::get_node(file_path const & p) const { - split_path sp; - p.split(sp); - split_path dirname; - path_component basename; - dirname_basename(sp, dirname, basename); - - MM(sp); MM(*this); - + MM(p); I(has_root()); - if (dirname.empty()) - { - I(null_name(basename)); - return root_dir; - } - - dir_t d = root_dir; - for (split_path::const_iterator i = dirname.begin()+1; i != dirname.end(); ++i) - d = downcast_to_dir_t(d->get_child(*i)); - return d->get_child(basename); + node_t n = get_node_worker(*this, p); + I(n); + return n; } bool @@ -620,37 +625,12 @@ roster_t::has_node(file_path const & p) bool roster_t::has_node(file_path const & p) const { - split_path sp; - p.split(sp); - split_path dirname; - path_component basename; - dirname_basename(sp, dirname, basename); - - if (dirname.empty()) - { - I(null_name(basename)); - return has_root(); - } - - // If we have no root, we *definitely* don't have a non-root path - if (!has_root()) - return false; - - dir_t d = root_dir; - for (split_path::const_iterator i = dirname.begin()+1; i != dirname.end(); ++i) - { - if (d->children.find(*i) == d->children.end()) - return false; - node_t child = d->get_child(*i); - if (!is_dir_t(child)) - return false; - d = downcast_to_dir_t(child); - } - return d->children.find(basename) != d->children.end(); + MM(*this); + MM(p); + return static_cast(get_node_worker(*this, p)); } - node_t roster_t::get_node(node_id nid) const { @@ -810,19 +790,12 @@ roster_t::attach_node(node_id nid, file_ void roster_t::attach_node(node_id nid, file_path const & p) { - split_path sp; - p.split(sp); - split_path dirname; - path_component basename; - dirname_basename(sp, dirname, basename); - - MM(sp); - - if (dirname.empty()) + MM(p); + if (p.empty()) // attaching the root node - attach_node(nid, the_null_node, basename); + attach_node(nid, the_null_node, the_null_component); else - attach_node(nid, get_node(file_path(dirname))->self, basename); + attach_node(nid, get_node(p.dirname())->self, p.basename()); } void @@ -2410,7 +2383,7 @@ roster_t::extract_path_set(set