# # # patch "file_io.cc" # from [3214c2cad3ec630d8466926bd4bae693de9184a0] # to [6c9c825346a1256c0e83b52302512ea39e1687b8] # # patch "file_io.hh" # from [2082dc3c8480400f32fcbe1c4d881d7512de2204] # to [0ad781436181e45effc327ca11ab7647ca8b2e9e] # # patch "work.cc" # from [39e5c9ecd7f5209dbcbb7e631d6fc044296a4a67] # to [d0ac482a5c29fe016912f98c89ae141f3c04a322] # # patch "work.hh" # from [2e87d93b08c16ef877483f69594636c480d0f97f] # to [394cfb37fa7d52006048ccf4f88059f18ec74d1c] # ============================================================ --- file_io.cc 3214c2cad3ec630d8466926bd4bae693de9184a0 +++ file_io.cc 6c9c825346a1256c0e83b52302512ea39e1687b8 @@ -484,8 +484,6 @@ { write_data_impl(path, data, tmpdir / (boost::format("data.tmp.%d") % get_process_id()).str()); - - } tree_walker::~tree_walker() {} @@ -533,8 +531,8 @@ } if (fs::is_directory(entry)) { - walker.visit_dir(p); - walk_tree_recursive(entry, rel_entry, walker); + if (walker.visit_dir(p)) + walk_tree_recursive(entry, rel_entry, walker); } else { @@ -545,9 +543,10 @@ } } -void +bool tree_walker::visit_dir(file_path const & path) { + return true; } @@ -573,10 +572,10 @@ walker.visit_file(path); break; case path::directory: - walker.visit_dir(path); - walk_tree_recursive(system_path(path).as_external(), - path.as_external(), - walker); + if (walker.visit_dir(path)) + walk_tree_recursive(system_path(path).as_external(), + path.as_external(), + walker); break; } } ============================================================ --- file_io.hh 2082dc3c8480400f32fcbe1c4d881d7512de2204 +++ file_io.hh 0ad781436181e45effc327ca11ab7647ca8b2e9e @@ -101,7 +101,8 @@ class tree_walker { public: - virtual void visit_dir(file_path const & path); + // returns true if the directory should be descended into + virtual bool visit_dir(file_path const & path); virtual void visit_file(file_path const & path) = 0; virtual ~tree_walker(); }; ============================================================ --- work.cc 39e5c9ecd7f5209dbcbb7e631d6fc044296a4a67 +++ work.cc d0ac482a5c29fe016912f98c89ae141f3c04a322 @@ -28,10 +28,11 @@ string const attr_file_name(".mt-attrs"); -void +bool file_itemizer::visit_dir(file_path const & path) { this->visit_file(path); + return true; } void @@ -347,7 +348,35 @@ update_any_attrs(app); } +void +perform_pivot_root(file_path const & new_root, file_path const & put_old, + app_state & app) +{ +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 base_roster, new_roster; + get_base_and_current_roster_shape(base_roster, new_roster, nis, app); + + 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); + { + split_path new_root_MT; + (new_root / bookkeeping_root).split(new_root_MT); + N(!new_roster.has_node(new_root_MT), + F("proposed new root directory '%s' contains illegal path %s") % new_root % bookkeeping_root); + } + + node_id old_root_nid = new_roster.detach_node(root_sp); + node_id new_root_nid = new_roster.detach_node(new_root_sp); + new_roster.attach_node(new_root_nid, root_sp); +} + + // work file containing rearrangement from uncommitted adds/drops/renames std::string const work_file_name("work"); ============================================================ --- work.hh 2e87d93b08c16ef877483f69594636c480d0f97f +++ work.hh 394cfb37fa7d52006048ccf4f88059f18ec74d1c @@ -55,7 +55,7 @@ path_set & ignored; file_itemizer(app_state & a, path_set & k, path_set & u, path_set & i) : app(a), known(k), unknown(u), ignored(i) {} - virtual void visit_dir(file_path const & path); + virtual bool visit_dir(file_path const & path); virtual void visit_file(file_path const & path); }; @@ -70,6 +70,10 @@ file_path const & dst_dir, app_state & app); +void +perform_pivot_root(file_path const & new_root, file_path const & put_old, + app_state & app); + // the "work" file contains the current cset representing uncommitted // add/drop/rename operations (not deltas)