# # # patch "cmd_ws_commit.cc" # from [9cc4e1d34ff79de8fc704a4a4472433e947a35fe] # to [3e700eabd19157766ac68d36a296f970ee81457e] # # patch "roster.cc" # from [113187ebdf575e645f20efa657db7517d349636c] # to [00d94b08581f20a52f81828baa270a3ba9cb2f70] # # patch "roster.hh" # from [d9a92727756deb5917cede674ff95c44e933f0ff] # to [3d64ba3885d4d9daa5534125d0b58ed00307fb11] # ============================================================ --- cmd_ws_commit.cc 9cc4e1d34ff79de8fc704a4a4472433e947a35fe +++ cmd_ws_commit.cc 3e700eabd19157766ac68d36a296f970ee81457e @@ -210,11 +210,8 @@ CMD(revert, "revert", "", CMD_REF(worksp make_cset(old_roster, restricted_roster, preserved); - // Leave the preserved cset pending in MTN/revision - // which must be valid against the old roster. + // The preserved cset will be left pending in MTN/revision - check_restricted_cset(old_roster, preserved); - // if/when reverting through the editable_tree interface use // make_cset(new_roster, restricted_roster, reverted); // to get a cset that gets us back to the restricted roster ============================================================ --- roster.cc 113187ebdf575e645f20efa657db7517d349636c +++ roster.cc 00d94b08581f20a52f81828baa270a3ba9cb2f70 @@ -2310,145 +2310,22 @@ make_restricted_roster(roster_t const & selected.erase(n->first); } - N(problems == 0, F("invalid restriction")); + // it would be good to check this and do a check_sane but these seem to + // cause some test breakage - // TODO: add some sanity checks here... restricted.check_sane()? -} + // if (!restricted.has_root()) + // { + // // done to avoid tripping I(has_root()) in check_sane + // W(F("restriction excludes addition of root directory")); + // problems++; + // } + N(problems == 0, F("invalid restriction")); -// TODO: possibly delete all this checking stuff -class editable_roster_for_check - : public editable_roster_base -{ - public: - editable_roster_for_check(roster_t & r); - virtual node_id detach_node(file_path const & src); - virtual void drop_detached_node(node_id nid); - virtual void attach_node(node_id nid, file_path const & dst); - int problems; - - private: - temp_node_id_source nis; - map > > detached_dirs; -}; - -editable_roster_for_check::editable_roster_for_check(roster_t & r) - : editable_roster_base(r, nis), problems(0) -{ - node_map nodes = r.all_nodes(); - - if (!nodes.empty()) - { - node_map::const_iterator i = nodes.begin(); - node_id max = i->first; - - for (; i != nodes.end(); ++i) - { - if (i->first > max) - max = i->first; - } - - // ensure our node source starts beyond the max temp node in this roster - while (nis.next() <= max) - ; - } + // restricted.check_sane(true); } -node_id -editable_roster_for_check::detach_node(file_path const & src) -{ - node_t n = r.get_node(src); - if (is_dir_t(n)) - { - dir_t dir = downcast_to_dir_t(n); - vector children; - for (dir_map::const_iterator - i = dir->children.begin(); i != dir->children.end(); ++i) - { - children.push_back(i->first); - } - detached_dirs.insert(make_pair(dir->self, - make_pair(src, children))); - } - - return this->editable_roster_base::detach_node(src); -} - void -editable_roster_for_check::drop_detached_node(node_id nid) -{ - node_t n = r.get_node(nid); - if (is_dir_t(n) && !downcast_to_dir_t(n)->children.empty()) - { - map > >::const_iterator - i = detached_dirs.find(nid); - I(i != detached_dirs.end()); - - file_path dir = i->second.first; - for (vector::const_iterator - p = i->second.second.begin(); p != i->second.second.end(); ++p) - { - W(F("restriction includes deletion of '%s' " - "but excludes deletion of '%s'") - % dir % (dir / *p)); - problems++; - } - } - else - { - this->editable_roster_base::drop_detached_node(nid); - } -} - -void -editable_roster_for_check::attach_node(node_id nid, file_path const & dst) -{ - file_path parent = dst.dirname(); - - if (!r.has_node(parent) && !dst.empty()) - { - W(F("restriction excludes addition of '%s' but includes addition of '%s'") - % parent % dst); - problems++; - } - else - { - this->editable_roster_base::attach_node(nid, dst); - } -} - - -// TODO: delete this ?!? -// it may still be needed for revert which has to check that the excluded cset -// still makes sense against the *old* roster -// before revert: -// old roster restricted roster new roster -// after revert: -// old roster new roster - -void -check_restricted_cset(roster_t const & roster, cset const & cs) -{ - // This command checks that a cset generated by make_restricted_cset still - // is sensical when applied to the given roster -- e.g., it does not - // include a deletion of a directory that would be empty, except that some - // of the deletions/renames that emptied it were not included in the - // restriction, it does not include the addition of a file when the - // addition of its parent directory was not included, etc. - - MM(roster); - MM(cs); - - // make a copy of the roster to apply the cset to destructively - roster_t tmp(roster); - editable_roster_for_check e(tmp); - cs.apply_to(e); - - N(e.problems == 0, F("invalid restriction")); -} - - -void select_nodes_modified_by_cset(cset const & cs, roster_t const & old_roster, roster_t const & new_roster, ============================================================ --- roster.hh d9a92727756deb5917cede674ff95c44e933f0ff +++ roster.hh 3d64ba3885d4d9daa5534125d0b58ed00307fb11 @@ -368,9 +368,6 @@ void node_restriction const & mask); void -check_restricted_cset(roster_t const & roster, cset const & cs); - -void select_nodes_modified_by_cset(cset const & cs, roster_t const & old_roster, roster_t const & new_roster,