aboutsummaryrefslogtreecommitdiff
path: root/odb
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-04-26 14:41:59 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-04-26 14:41:59 +0200
commita8781515e5241b405139c904fb5875108344a5c0 (patch)
tree07b03c522c790d4d571841c747fe5ea770e6e36a /odb
parent89120cf7addb304c1d1b029f1edae108e94ba023 (diff)
Fix bug in diff'ing models of same version
Diffstat (limited to 'odb')
-rw-r--r--odb/relational/changelog.cxx25
1 files changed, 20 insertions, 5 deletions
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<changeset> (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<alters> (r,
- l.contains_changeset_empty ()
- ? static_cast<qscope&> (l.model ())
- : l.contains_changeset_back ().changeset ());
+ if (o.version () == n.version ())
+ l.new_edge<alters> (r, o);
+ else
+ {
+ if (l.contains_changeset_empty ())
+ {
+ model& m (l.model ());
+ assert (o.version () == m.version ());
+ l.new_edge<alters> (r, m);
+ }
+ else
+ {
+ changeset& c (l.contains_changeset_back ().changeset ());
+ assert (o.version () == c.version ());
+ l.new_edge<alters> (r, c);
+ }
+ }
{
trav_rel::model model;