Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF Diff/Merge » Inverting and merging differences
Inverting and merging differences [message #1049160] Thu, 25 April 2013 13:05 Go to next message
Miklós Földényi is currently offline Miklós FöldényiFriend
Messages: 6
Registered: October 2012
Junior Member
Hi!

I am having some newbie trouble using EMF Diff/Merge. It might even be, that this tool is not ideal for my needs, but I got so confused I am not sure I can decide that by myself, so I present my use case below:

Assume I have an EMF meta-model (that can be considered non-changing for our purposes) and an EMF model instance of this meta-model. I'll refer to the current state of this instance as State 1 (S1).

I want to execute changes on my model instance:
C1:S1->S2 (executing Change 1 in State 1 results in State 2)
C2:S1->S3
C3:S2->S4

Executing C1, C2 and C3 in order, results in the following state transition: (to execute C3 I have to move the model into S2 first)
S1->S2->S1->S3->S2->S4

The Green transitions are trivial. The Orange and Red transitions are my problems.

The Orange requires me to "undo" a transition, which I cannot do by undoing the RecordingCommands, for reasons outside of the scope of my question. This I would like to achieve, by calculating the Diff1 S1->S2 and executing it's inverse.

The Red transition is a "state jump", which I would like to achieve by calculating Diff2 S1->S3, then merging Diff1 and Diff2 into Diff3 in such a way, that executing Diff3 in S3 will result in S2. (this would mean (inverse Diff2)+Diff1)

This is important for me since I can be pretty deep down in the change tree and always walking up to the root then back down can be very expensive. Also, due to a large number of listeners on the model instance, I would like to achieve the S3->S2 state transition with the least amount of model modifications.


So my questions are:
- Can a Diff be calculated and stored for later use in this way?
- Can it be inverted?
- Can it be merged with other Diffs (prior to merging them with the model instance) assuming they have a common state "end"? (like in the case above, S1 appearing in Diff1 S1->S2 and in inverse Diff2 S3->S1, so S3->S1->S2 is a valid transition sequence)

Thanks!
Re: Inverting and merging differences [message #1049935 is a reply to message #1049160] Fri, 26 April 2013 13:21 Go to previous messageGo to next message
Olivier Constant is currently offline Olivier ConstantFriend
Messages: 106
Registered: January 2012
Senior Member
Hello Miklós,

A Diff (IComparison in EMF Diff/Merge) is the description of a relationship between two models in terms of what is present in one and missing in the other. A Diff is thus not self-contained since its definition relies on that of the two models. It seems to me that what you need is a Patch: a self-contained description of changes that can be applied to a model. I don't know about any tool support for model patches. We had thoughts about introducing this notion in EMF Diff/Merge but nothing is planned as of today.

> - Can a Diff be calculated and stored for later use in this way?

It is not meant to. Given your model M1 in state S1, you could save Diff C1 as (IComparison between S1 and S2 + model in state S2). But that would be of very little interest since that requires to have the entire model in state S2 at hand - let's call it M2. You could, however, try to reduce M2 to the minimal set of elements required for the definition of C1. That would bring you closer to the definition of a Patch, except that this Patch would still only be applicable to M1. That could be ok for you, but it is unclear to me since you reveal little about the context of your need. In any case, there is clearly no direct tool support for your need in EMF Diff/Merge.

> - Can it be inverted?

Yes and no. A Diff has no direction. If you consider C1 as a Diff, it can be used to change S1 to S2 or S2 to S1. But that is because the definition of C1 is made of the definition of S1 and S2, so let's say it's cheating.

> - Can it be merged with other Diffs ?

No, there is no support for that. That would require the notion of Patch to be properly defined.

Regards,
Olivier
Re: Inverting and merging differences [message #1053078 is a reply to message #1049935] Thu, 02 May 2013 11:05 Go to previous message
Miklós Földényi is currently offline Miklós FöldényiFriend
Messages: 6
Registered: October 2012
Junior Member
Thanks for the very informative answer Olivier!

I did not mean to be cryptic about my reason of asking, I just did not want to over complicate my question.

I am poking around Design Space Exploration. I meant to build a low(er) level generic search tree, which would provide services to the DSE engine. One such service would be the ability to transition the model between states in the already walked search tree.

My idea was to somehow break down the problem into having the diffs (which as you've said, are really more like patches) of every model change (<== the edges in the tree), then if I need to "jump" in the tree, I find the shortest path from origin to target in the tree graph and execute the chain of patches (or inverted patches) in sequence.

For this, it is now obvious for me, EMF/DiffMerge is not the answer. I found a project that was a lot closer to my goals, an extension to EMF Compare, called Epatch. I am yet to check out if that project is still maintained or not and if I can use it.

Thanks again for your excellent answer! It gave me a huge boost in understanding what EMF/DiffMerge and it's approach is!

Miklós

Previous Topic:Differences with EMF Compare 2
Next Topic:How to show the GUI programmatically?
Goto Forum:
  


Current Time: Thu Mar 28 10:04:10 GMT 2024

Powered by FUDForum. Page generated in 0.02380 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top