# # patch "ChangeLog" # from [d3e24bb1960a28fcdf6539ab28650760cf3f7f4c] # to [321cebaad41a0e794e9d8be4a2eef0448c617984] # # patch "revision.cc" # from [df925b5cb45b76df6a85d2b7da0a100121958331] # to [55e8cf987d6eb6854eb178ba131619312837bb28] # ======================================================================== --- ChangeLog d3e24bb1960a28fcdf6539ab28650760cf3f7f4c +++ ChangeLog 321cebaad41a0e794e9d8be4a2eef0448c617984 @@ -1,3 +1,7 @@ +2005-10-08 Nathaniel Smith + + * revision.cc (check_sane_history): Remove. + 2005-08-31 Marcel van der Boom * std_hooks.lua (execute_confirm): New function. ======================================================================== --- revision.cc df925b5cb45b76df6a85d2b7da0a100121958331 +++ revision.cc 55e8cf987d6eb6854eb178ba131619312837bb28 @@ -96,187 +96,6 @@ } -// Traces history back 'depth' levels from 'child_id', ensuring that -// historical information is consistent within this subgraph. -// The child must be in the database already. -// -// "Consistent" currently means that we compose manifests along every path (of -// any length) that terminates at the child, and for each one check that paths -// that should be the same in fact are the same, and that the calculated -// change sets can be applied to the old manifests to create the new -// manifest. -// -// We also make a special check for merge nodes, where if the previous -// paragraph wasn't enough to get us back to a common ancestor, we also search -// all the way up to a common ancestor and make the same check, because that's -// the invariant that merge is actually required to preserve. -// -// NB: While this function has some invariants in it itself, a lot of its -// purpose is just to exercise all the invariants inside change_set.cc. So -// don't remove those invariants. (As if you needed another reason...) - -/* -// FIXME_ROSTERS: disabled until rewritten to use rosters -void -check_sane_history(revision_id const & child_id, - int depth, - app_state & app) -{ - // We are, unfortunately, still quite slow. So we want to give at least a - // little feedback. Let's print exactly one warning, on the _second_ time - // we are called within one run -- just checking one revision isn't too - // slow, so no need to print anything on "commit", but usually if we're - // checking 2 revisions we're checking a lot more. - // FIXME: make sanity checking faster, so we can remove this kluge - // altogether... - static int num_checked = 0; - ++num_checked; - if (num_checked == 2) - P(F("verifying new revisions (this may take a while)\n")); - - L(F("Verifying revision %s has sane history (to depth %i)\n") - % child_id % depth); - - typedef boost::shared_ptr shared_cs; - // (ancestor, change_set from ancestor to child) - std::map changesets; - - manifest_id m_child_id; - app.db.get_revision_manifest(child_id, m_child_id); - manifest_map m_child; - app.db.get_manifest(m_child_id, m_child); - - std::set frontier; - frontier.insert(child_id); - - while (depth-- > 0) - { - std::set next_frontier; - - for (std::set::const_iterator i = frontier.begin(); - i != frontier.end(); - ++i) - { - revision_id current_id = *i; - revision_set current; - app.db.get_revision(current_id, current); - // and the parents's manifests to the manifests - // and the change_set's to the parents to the changesets - for (edge_map::const_iterator j = current.edges.begin(); - j != current.edges.end(); - ++j) - { - revision_id old_id = edge_old_revision(j); - manifest_id m_old_id = edge_old_manifest(j); - change_set old_to_current_changes = edge_changes(j); - if (!null_id(old_id)) - next_frontier.insert(old_id); - - L(F("Examining %s -> %s\n") % old_id % child_id); - - // build the change_set - // if - shared_cs old_to_child_changes_p = shared_cs(new change_set); - if (current_id == child_id) - *old_to_child_changes_p = old_to_current_changes; - else - { - shared_cs current_to_child_changes_p; - I(changesets.find(current_id) != changesets.end()); - current_to_child_changes_p = changesets.find(current_id)->second; - concatenate_change_sets(old_to_current_changes, - *current_to_child_changes_p, - *old_to_child_changes_p); - } - MM(*old_to_child_changes_p); - - // we have the change_set; now, is it one we've seen before? - if (changesets.find(old_id) != changesets.end()) - { - // If it is, then make sure the paths agree on the - // changeset. - MM(*changesets.find(old_id)->second); - I(*changesets.find(old_id)->second == *old_to_child_changes_p); - } - else - { - // If not, this is the first time we've seen this. - // So store it in the map for later reference: - changesets.insert(std::make_pair(old_id, old_to_child_changes_p)); - // and check that it works: - - manifest_map purported_m_child; - // The null revision has empty manifest, which is the - // default. - if (!null_id(old_id)) - app.db.get_manifest(m_old_id, purported_m_child); - apply_change_set(*old_to_child_changes_p, purported_m_child); - MM(purported_m_child); - MM(m_child); - I(purported_m_child == m_child); - } - } - } - frontier = next_frontier; - } - - // Finally, there's a danger that if we have a long divergence, then after a - // merge, the common ancestor will be far back enough that the above - // depth-limited search won't have any idea whether the ancestry invariants - // are actually preserved. So do an additional check on merge revisions, to - // make sure that the paths to both ways going back to their parents's - // common ancestor give the same change_set (i.e., this is a valid merge at - // all). - if (!global_sanity.relaxed) - { - revision_set child_rev; - app.db.get_revision(child_id, child_rev); - // Nothing inherently impossible about having more than 2 parents, but if - // you come up with some case where it should be possible then you'll - // have to also adjust the code below to figure out what "common - // ancestor" means. - I(child_rev.edges.size() <= 2); - if (child_rev.edges.size() != 2) - return; - edge_map::const_iterator i = child_rev.edges.begin(); - revision_id parent_left = edge_old_revision(i); - change_set left_edge = edge_changes(i); - ++i; - revision_id parent_right = edge_old_revision(i); - change_set right_edge = edge_changes(i); - ++i; - I(i == child_rev.edges.end()); - revision_id lca; - if (!find_least_common_ancestor(parent_left, parent_right, lca, app)) - { - L(F("%s and %s have no common ancestor, so done\n") - % parent_left % parent_right); - return; - } - if (changesets.find(lca) != changesets.end()) - { - L(F("already checked common ancestor, so done\n")); - return; - } - L(F("%s is a merge; verifying paths to common ancestor %s are sane\n") - % child_id % lca); - // we have a merge node, with an lca sufficiently far back in history - // that we haven't yet figured out whether this is a valid merge or - // not. so find out. - change_set cs_parent_left, cs_parent_right, cs_left, cs_right; - MM(cs_parent_left); - MM(cs_parent_right); - MM(cs_left); - MM(cs_right); - calculate_composite_change_set(lca, parent_left, app, cs_parent_left); - calculate_composite_change_set(lca, parent_right, app, cs_parent_right); - concatenate_change_sets(cs_parent_left, left_edge, cs_left); - concatenate_change_sets(cs_parent_right, right_edge, cs_right); - I(cs_left == cs_right); - } -} -*/ - // calculating least common ancestors is a delicate thing. // // it turns out that we cannot choose the simple "least common ancestor"