From a8781515e5241b405139c904fb5875108344a5c0 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 26 Apr 2013 14:41:59 +0200 Subject: Fix bug in diff'ing models of same version --- odb/relational/changelog.cxx | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'odb') diff --git a/odb/relational/changelog.cxx b/odb/relational/changelog.cxx index 585a2c4..af1dcea 100644 --- a/odb/relational/changelog.cxx +++ b/odb/relational/changelog.cxx @@ -412,12 +412,27 @@ namespace relational { changeset& r (l.new_node (n.version ())); - // Set the alters edge for lookup. + // Set the alters edge for lookup. If we are diff'ing two models of + // the same version, then use the old model as a base. Otherwise use + // the tip of changelog (it should correspond to the old model). // - l.new_edge (r, - l.contains_changeset_empty () - ? static_cast (l.model ()) - : l.contains_changeset_back ().changeset ()); + if (o.version () == n.version ()) + l.new_edge (r, o); + else + { + if (l.contains_changeset_empty ()) + { + model& m (l.model ()); + assert (o.version () == m.version ()); + l.new_edge (r, m); + } + else + { + changeset& c (l.contains_changeset_back ().changeset ()); + assert (o.version () == c.version ()); + l.new_edge (r, c); + } + } { trav_rel::model model; -- cgit v1.1