# # # patch "rcs_import.cc" # from [64e76f60aa1f60608af80c165240b3cc6567f62f] # to [1d03445dd998c1e0c2e83725768b324ee75ac509] # # patch "roster_merge.cc" # from [e4337633b15ec3ba3f9c9d47e72e955aa2a972f5] # to [77ae7b51617a9f59dfb97941a7b04fa8d250e25c] # # patch "work.cc" # from [0feedb585ed60dbc8cb3f204a925e094255c5c9d] # to [1868eaed750a170cf4b0e69e7906c3582dee771a] # ============================================================ --- rcs_import.cc 64e76f60aa1f60608af80c165240b3cc6567f62f +++ rcs_import.cc 1d03445dd998c1e0c2e83725768b324ee75ac509 @@ -1012,7 +1012,7 @@ cluster_consumer app_state & app; string const & branchname; cvs_branch const & branch; - set created_dirs; + set created_dirs; map live_files; ticker & n_revisions; @@ -1043,7 +1043,7 @@ cluster_consumer ticker & n_revs); void consume_cluster(cvs_cluster const & c); - void add_missing_parents(split_path const & sp, cset & cs); + void add_missing_parents(file_path const & sp, cset & cs); void build_cset(cvs_cluster const & c, cset & cs); void store_auxiliary_certs(prepared_revision const & p); void store_revisions(); @@ -1380,21 +1380,16 @@ void } void -cluster_consumer::add_missing_parents(split_path const & sp, cset & cs) +cluster_consumer::add_missing_parents(file_path const & path, cset & cs) { - split_path tmp(sp); - if (tmp.empty()) + if (created_dirs.find(path) != created_dirs.end()) return; - tmp.pop_back(); - while (!tmp.empty()) - { - if (created_dirs.find(tmp) == created_dirs.end()) - { - safe_insert(created_dirs, tmp); - safe_insert(cs.dirs_added, file_path(tmp)); - } - tmp.pop_back(); - } + + if (!path.empty()) + add_missing_parents(path.dirname(), cs); + + safe_insert(created_dirs, path); + safe_insert(cs.dirs_added, path); } void @@ -1405,8 +1400,6 @@ cluster_consumer::build_cset(cvs_cluster i != c.entries.end(); ++i) { file_path pth = file_path_internal(cvs.path_interner.lookup(i->first)); - split_path sp; - pth.split(sp); file_id fid(cvs.file_version_interner.lookup(i->second.version)); if (i->second.live) @@ -1414,9 +1407,9 @@ cluster_consumer::build_cset(cvs_cluster map::const_iterator e = live_files.find(i->first); if (e == live_files.end()) { - add_missing_parents(sp, cs); + add_missing_parents(pth.dirname(), cs); L(FL("adding entry state '%s' on '%s'") % fid % pth); - safe_insert(cs.files_added, make_pair(sp, fid)); + safe_insert(cs.files_added, make_pair(pth, fid)); live_files[i->first] = i->second.version; } else if (e->second != i->second.version) @@ -1425,7 +1418,7 @@ cluster_consumer::build_cset(cvs_cluster L(FL("applying state delta on '%s' : '%s' -> '%s'") % pth % old_fid % fid); safe_insert(cs.deltas_applied, - make_pair(sp, make_pair(old_fid, fid))); + make_pair(pth, make_pair(old_fid, fid))); live_files[i->first] = i->second.version; } } ============================================================ --- roster_merge.cc e4337633b15ec3ba3f9c9d47e72e955aa2a972f5 +++ roster_merge.cc 77ae7b51617a9f59dfb97941a7b04fa8d250e25c @@ -842,9 +842,7 @@ struct name_shared_stuff : public virtua virtual file_path path_for(scalar_val val) = 0; path_component pc_for(scalar_val val) { - split_path sp; - path_for(val).split(sp); - return idx(sp, sp.size() - 1); + return path_for(val).basename(); } virtual node_id parent_for(scalar_val val) = 0; ============================================================ --- work.cc 0feedb585ed60dbc8cb3f204a925e094255c5c9d +++ work.cc 1868eaed750a170cf4b0e69e7906c3582dee771a @@ -561,12 +561,26 @@ public: {} virtual bool visit_dir(file_path const & path); virtual void visit_file(file_path const & path); - void add_node_for(file_path const & path); + void add_nodes_for(file_path const & path, file_path const & goal); }; void -addition_builder::add_node_for(file_path const & path) +addition_builder::add_nodes_for(file_path const & path, + file_path const & goal) { + // this check suffices to terminate the recursion; our caller guarantees + // that the roster has a root node, which will be a directory. + if (ros.has_node(path)) + { + N(is_dir_t(ros.get_node(path)), + F("cannot add %s, because %s is recorded as a file " + "in the workspace manifest") % goal % path); + return; + } + + add_nodes_for(path.dirname(), goal); + P(F("adding %s to workspace manifest") % path); + node_id nid = the_null_node; switch (get_path_status(path)) { @@ -620,25 +634,7 @@ addition_builder::visit_file(file_path c } 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(file_path(prefix))) - { - P(F("adding %s to workspace manifest") % file_path(prefix)); - add_node_for(file_path(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 " - "in the workspace manifest") % path % file_path(prefix)); - break; - } - } + add_nodes_for(path, path); } struct editable_working_tree : public editable_tree