# # patch "ChangeLog" # from [af0892bf7b0572c6a7c2802b26af3429957b4f8e] # to [71121fbd00c6995192b9c8ec570b862da370607c] # # patch "change_set.cc" # from [2c23e02d428444eb487bbb1d81dd71d8b1e8947e] # to [fb30e69bb9b5f0144638087ddc54bd7df84399b4] # # patch "pcdv.cc" # from [141ba3bc8d108539e711c63ccf0c2faf05cf04f7] # to [633581c14140fd3c54eccc44a755a5442057d4ba] # # patch "restrictions.cc" # from [03e4eb83e836f713c20e4d1f94fe26f792e18d51] # to [24de26cfce99c99c3491eb25c0c1292f8d1d851a] # ======================================================================== --- ChangeLog af0892bf7b0572c6a7c2802b26af3429957b4f8e +++ ChangeLog 71121fbd00c6995192b9c8ec570b862da370607c @@ -1,3 +1,9 @@ +2005-08-26 Timothy Brownawell + + * change_set.cc, pcdv.cc, restrictions.cc: Try to make directory + deletion work. (Unsuccesful, but left in because it doesn't seem to + break anything.) + 2005-08-24 Timothy Brownawell * tests/t_add_vs_commit.at: Fix BASE_REVISION usage for the working ======================================================================== --- change_set.cc 2c23e02d428444eb487bbb1d81dd71d8b1e8947e +++ change_set.cc fb30e69bb9b5f0144638087ddc54bd7df84399b4 @@ -211,6 +211,15 @@ bool change_set::path_rearrangement::has_deleted_file(file_path const & file) const { + std::vector spl; + split_path(file, spl); + for (spl.pop_back(); !spl.empty(); spl.pop_back()) + { + file_path recon; + compose_path(spl, recon); + if (deleted_dirs.find(recon) != deleted_dirs.end()) + return true; + } return deleted_files.find(file) != deleted_files.end(); } @@ -808,10 +817,41 @@ compose_path(old_name, old_path); } - if (!null_name(path_item_name(new_item))) + bool del_parent = false; + { + bool last = false;// we don't want to count the last item + get_full_path(pa.second, curr, new_name); + for (std::vector::const_iterator + i = new_name.begin(); i != new_name.end(); ++i) + { + del_parent = del_parent || last; + last = null_name(*i); + } + } + if (!null_name(path_item_name(new_item))) +/* { + std::vector pdir_new_name; + tid p = path_item_parent(old_item); + get_full_path(pa.second, p, pdir_new_name); + for (std::vector::const_iterator + i = pdir_new_name.begin(); i != pdir_new_name.end(); ++i) + { + if (null_name(*i)) + del_parent = true; + } + } + else*/ { + bool last = false;// we don't want to count the last item get_full_path(pa.second, curr, new_name); - compose_path(new_name, new_path); + for (std::vector::const_iterator + i = new_name.begin(); i != new_name.end(); ++i) + { + del_parent = del_parent || last; + last = null_name(*i); + } + if (!del_parent) + compose_path(new_name, new_path); } if (old_path == new_path) @@ -823,12 +863,17 @@ */ continue; } + if (del_parent) + { + L(F("skipping '%1%' with deleted parent") % old_path); + continue; + } - /* +// /* L(F("analyzing %s %d : '%s' -> '%s'\n") % (path_item_type(old_item) == ptype_directory ? "directory" : "file") % curr % old_path % new_path); - */ +// */ if (null_name(path_item_name(old_item))) { @@ -1395,6 +1440,8 @@ // a path P = DIR/LEAF is "killed" by a path_analysis iff the // directory node named DIR in the post-state contains LEAF in the // pre-state, and does not contain LEAF in the post-state + // + //FIXME: what if the node DIR no longer exists? boost::shared_ptr first_node = i->second; boost::shared_ptr second_node = j->second; @@ -1411,6 +1458,15 @@ file_path killed_path; get_full_path(a.second, dir_tid, killed_name); killed_name.push_back(first_name); + bool del_parent = false; + for (std::vector::const_iterator + i = killed_name.begin(); i != killed_name.end(); ++i) + { + if (null_name(*i)) + del_parent = true; + } + if (del_parent) + break; compose_path(killed_name, killed_path); killed.insert(killed_path); } @@ -1622,7 +1678,9 @@ if (!b.rearrangement.has_deleted_file(del_pth) || b.rearrangement.has_added_file(del_pth) || b.rearrangement.has_renamed_file_dst(del_pth)) - concatenated.deltas.insert(*del); + { + concatenated.deltas.insert(*del); + } } } @@ -1833,6 +1891,8 @@ { std::pair::iterator, bool> r; r = ip.insert(std::make_pair(i->first, itempaths())); + if (r.first->second.anc == file_path()) + continue; I((*i).second.size() == 1); r.first->second.ahash = file_id(itx.lookup(*(*i).second.begin())); } @@ -1843,6 +1903,8 @@ { std::pair::iterator, bool> r; r = ip.insert(std::make_pair(i->first, itempaths())); + if (r.first->second.left == file_path()) + continue; I((*i).second.size() == 1); r.first->second.lhash = file_id(itx.lookup(*(*i).second.begin())); } @@ -1853,6 +1915,8 @@ { std::pair::iterator, bool> r; r = ip.insert(std::make_pair(i->first, itempaths())); + if (r.first->second.right == file_path()) + continue; I((*i).second.size() == 1); r.first->second.rhash = file_id(itx.lookup(*(*i).second.begin())); } @@ -1863,6 +1927,8 @@ { std::pair::iterator, bool> r; r = ip.insert(std::make_pair(i->first, itempaths())); + if (r.first->second.merged == file_path()) + continue; if ((*i).second.size() == 1) { r.first->second.clean = true; @@ -2604,11 +2670,21 @@ } } +void dump(path_set const & obj, std::string & out) +{ + out.clear(); + for (path_set::const_iterator i = obj.begin(); i != obj.end(); ++i) + out += (*i)() + "\n"; +} + static inline void apply_path_rearrangement_slowpath(path_set const & old_ps, change_set::path_rearrangement const & pr, path_set & new_ps) { + MM(pr); + MM(old_ps); + MM(new_ps); pr.check_sane(); change_set::path_rearrangement a, b; a.added_files = old_ps; ======================================================================== --- pcdv.cc 141ba3bc8d108539e711c63ccf0c2faf05cf04f7 +++ pcdv.cc 633581c14140fd3c54eccc44a755a5442057d4ba @@ -1362,8 +1362,9 @@ std::set s = j->second.current_names(); I(s.size() == 1); file_path fp = out.get_full_name(*s.begin()); - I(!(fp == file_path())); done.insert(myid); + if (fp == file_path()) + continue;// parent dir was deleted std::pair::iterator, bool> r; r = outmap.insert(make_pair(cit.intern(fp()), myid)); if (r.first->second != myid) @@ -1424,6 +1425,7 @@ // ...find where it goes... if (type == deleted_file || type == deleted_dir) { + L(F("File %1% being deleted (%2%)") % from % current_id); current_item = current_item.rename(out.itx->intern(revision), item_id(-1), make_null_component()); @@ -1504,7 +1506,8 @@ std::set s = j->second.current_names(); I(s.size() == 1); file_path fp = out.get_full_name(*s.begin()); - I(!(fp == file_path())); + if (fp == file_path()) + continue;// parent dir was deleted std::pair::iterator, bool> r; r = outmap.insert(make_pair(cit.intern(fp()), myid)); if (r.first->second != myid) @@ -1750,7 +1753,7 @@ ++l, ++r; } - if (pre == post) + if (pre == post || (from == file_path() && to == file_path())) continue; else if (to == file_path()) { ======================================================================== --- restrictions.cc 03e4eb83e836f713c20e4d1f94fe26f792e18d51 +++ restrictions.cc 24de26cfce99c99c3491eb25c0c1292f8d1d851a @@ -194,6 +194,9 @@ apply_path_rearrangement(old_paths, included, new_paths); } + +void dump(path_set const & obj, std::string & out); + void calculate_restricted_revision(app_state & app, std::vector const & args, @@ -215,7 +218,11 @@ old_manifest_id, old_revision_id, m_old, old_paths, new_paths, cs->rearrangement, excluded); - + MM(old_paths); + MM(new_paths); + MM(*cs); + MM(m_old); + MM(m_new); build_restricted_manifest_map(new_paths, m_old, m_new, app); complete_change_set(m_old, m_new, *cs);