EMF Compare — User Guide

Version 3.2.0.201411250710

Table of Contents

  1. Getting Started
    1. Installing EMF Compare
      1. Marketplace Client
      2. Update Site
      3. Compatibility
    2. User Interface Breakdown
      1. Toolbar
      2. Signification of icons associated with differences
      3. After merge
  2. Launch Comparison
    1. Compare with local models
      1. Compare with each other
      2. Compare with local history
    2. Compare with remote models
      1. Compare with latest
      2. Compare two differing branches
  3. Customization
    1. Engines
      1. Match Engine
        1. Configure registered matching engine
          1. Matching strategy for default match engine
        2. Enable/Disable Match Engines
      2. For other engines
        1. Choose the default engine
    2. Post processors customization
      1. Model Resolvers
        1. Disable model resolution
        2. Choose a strategy
    3. User Interface customization
      1. Colors Customization
      2. Filters
      3. Groups
      4. Items providers
  4. Features
    1. Grouping Differences
    2. Filtering Differences
    3. Handling Conflicts
    4. Text Attribute Comparison
    5. Graphical Comparison
    6. Logical Model
    7. UML Specialization
  5. Logical Model View
    1. Toolbar
    2. Contextual Menu
  6. Known Bugs and Limitations
    1. Project names and location
      1. Cause
      2. Observed Symptoms
    2. Models out of the workspace
      1. Cause
      2. Observed Symptoms
  7. Other Materials

Getting Started

Installing EMF Compare

Marketplace Client

Using the bundled Eclipse marketplace client you can install EMF Compare in one click. Just type "emf compare", click on search, and then on install.

Update Site

EMF has been part of the Eclipse release train since Galileo, you can install it using the following update sites, depending on your platform. Note that the following are not meant to be visited in your internet browser; they must be pasted in the Help > Install New Software dialog of your Eclipse, as p2 repositories.

 http://download.eclipse.org/releases/luna
 http://download.eclipse.org/releases/kepler
 http://download.eclipse.org/releases/juno
 http://download.eclipse.org/releases/indigo
 http://download.eclipse.org/releases/helios
 http://download.eclipse.org/releases/galileo

The Download page lists more specific update sites if you wish to try one of the latest integration builds.

Compatibility

Please note that the EMF Compare development team does its best to maintain downward compatibility towards Helios (Eclipse 3.6). Following is the compatibility chart :

EMF Compare Eclipse 4.4 - EMF 2.10 Eclipse 4.3 - EMF 2.9 Eclipse 4.2 - EMF 2.8 Eclipse 3.8 - EMF 2.8 Eclipse 3.7 - EMF 2.7 Eclipse 3.6 - EMF 2.6 Eclipse 3.5 - EMF 2.5 Eclipse 3.4 - EMF 2.4 Eclipse 3.3 - EMF 2.3 Eclipse 3.2 - EMF 2.2
3.0                    
2.1                    
2.0                    
1.3                    
1.2                    
1.1                    
1.0                    

An empty cell indicates that the compatibility hasn't been tested for a particular combination.

User Interface Breakdown

The main points of interest are highlighted in the following picture :

EMF Compare's basic user interface

  1. Overview of the differences detected between the given two (or three) models.
  2. First version of the compared models.
  3. Second version of the compared models.
  4. This button will only be visible in the case of three-way comparisons (for example, comparing with a remote repository). It will make a third version of the compared model (the common ancestor of the two others) visible in the interface.
  5. When you select a difference in the top panel, the consequences of the merge of this difference are highlighted in green and red.

Toolbar

The toolbar displays the current status of the comparison and allows you to act on differences.

EMF Compare's user interface toolbar

  1. Gives the number of differences still to be merged, and the number of differences filtered from the view.
  2. Allows to change the direction of consequences that are highlighted in green and red in the top panel. You can either display the consequences of a merge from left to right or right to left.
  3. Allows you to merge the single, currently selected difference in a given direction (left to right, or right to left).
  4. Allows you to merge all non conflicting differences (left to right, or right to left) at once.
  5. Allows you to navigate through the detected differences.
  6. Allows to expand/collapse all differences in the top panel.
  7. This button will allow you to group differences together in the structural view. For example, grouping all "Additions" or "Deletions" together.
  8. This button will allow you to filter some differences out of the view according to a set predicate. For example, filtering out all "Additions" or "Moves".
  9. Allows to save the comparison model.

When you compare models with one in a read-only mode, some of actions proposed by the toolbar are slightly different. Indeed, if you compare a model with the local history, or you compare a model with a remote model stored in a repository, the latter is in a read-only mode. You will not able to merge differences to this read-only model. You will only accept or reject changes for your local model.

EMF Compare's user interface toolbar

  1. Allows to change the kind of consequences that are highlighted in green and red in the top panel. You can either display the consequences of accepting/rejecting the selected change.
  2. Allows you to accept the single, currently selected change.
  3. Allows you to reject the single, currently selected change.
  4. Allows you to accept all non conflicting changes at once.
  5. Allows you to reject all non conflicting changes at once.

Signification of icons associated with differences

When you run a comparison involving two models (a 2-way comparison), the icons associated with differences are:

When you run a comparison involving three models (a 3-way comparison), the icons associated with differences are:

After merge

The merged differences are displayed in gray and have a distinct icon.

When you compare models with one in a read-only mode, the icons are:

Launch Comparison

Once installed, you can compare your files (locally or from any Version Control System) as usual using the Compare With menu.

Compare with local models

Compare with each other

You can compare two or three models by selecting them and then using the Compare With > Each Other menu:

If you run a 3-way comparison (with 3 models), you have to select the ancestor of the comparison:

Compare with local history

You can also compare your local model with one of its previous version available in the local history. For that, use the Compare With > Local History menu:

Compare with remote models

The following displays the important part of a model life cycle with regards to the comparison. The full life cycle can be followed on Sample Use Case

Compare with latest

For this test, we'll suppose that you are trying to use EMF Compare on UML models shared under git. This will not go in details about UML and Git. We'll assume that you know how to manipulate an UML model, create or clone a git repository, share a project under it and use standard Git operations.

The name of our sample project will be "library". It contains a single folder "model" containing two models :

The model itself is a very simple library. Graphically speaking :

We commit this initial file as the original model. We then slightly modify it so that it now looks like :

But how do we know exactly what changed? Let's compare this with the file from the Git Index :

This will open a comparison editor. Let's select one of the differences displayed on its top half :

  1. We've selected the difference corresponding to the addition of attribute alias in the class Writer. A double-click on this difference updated our two panes below.
  2. alias has been added to the properties of Class Writer. In the model, this corresponds to a change to the reference ownedAttributes of the Writer Class. This sub-panel indicates the actual reference that was changed in oder to remind us of the context.
  3. This displays all values of the reference outlined in (2) as they are in the left model. This is where we see the new value, alias outlined.
  4. As for (2), this will display the context of the selected difference. The same reference will usually be displayed in both (2) and (4).
  5. This panel displays all values of the reference outlined in (4) as they are in the right model. In here, we see the location of alias outlined as an empty space. This rectangle is where the new value will be added if we merge it.

In this case, it is possible to merge towards the right : the index version of the model is editable, like any other file in the index. If we merge this difference towards the right, then it will exist an unstaged version of the model, and a staged version of the model, that will include the merged difference.

But this comparison with index is mainly useful in order to determine exactly what changed in our version. Let's commit our changes on the master branch.

Compare two differing branches

After that, our model can evolve, and evolve separately in multiple branches. Let's consider the case where we would have a master branch differing from a borrowables branch such as the two look like this (the branching point was the model we've already displayed above) :

Master Borrowables

Before we continue working on our Borrowables branch, we'd like to retrieve all modifications that have been pushed to master. With the "Borrowables" branch checked out, we'll use the Compare With > Branch, Tag or Reference action :

and compare with master :

This shows us all differences between our local copy and the master branch that were made since the 'branching' point.

Same as previously, you can navigate through the differences via the top panel, the structural view. There are three main kind of elements displayed here. Regular elements, that mimic the containment tree of your input models, are there to separate the various differences and let you know where they were actually detected. Then there are incoming differences, decorated with a blue arrow ( ) or a derived icon, and outgoing differences decorated with a gray arrow ( ) or a derived icon.

Incoming differences are changes that were made in the remote branch (here, master) since the branching point (common ancestor). Outgoing differences are changes that were made in the local copy (here, the borrowables branch) since the branching point.

There are no conflicts here, since UML uses computed identifiers (XMI ID) for the model elements. Thus, what looks like a conflict (the "Date" type that's been added on both branch in the types packages) is actually two distinct differences.

The interface also lets you display the common ancestor of both models through the icon. For example, if we select the Book class, we can see how it looks like on all three versions :

You can navigate through the differences using the appropriate actions, either the previous ( ) or the next ( ) difference.

The remaining two actions are those that actually interest us here we can either accept all non-conflicting differences to the local copy through or accept them one after the other through .

Accept all differences is not what we seek : we want to keep the changes we made locally, not revert them to the state they had before the branching point (which is their current state on master, the right side). We will then select all incoming differences (under the Right side node) one after the other and merge them one by one. This gives us our merged model :

Customization

Engines

During each comparison EMF Compare uses several engines (see Comparison process)

EMF Compare offers a way to configure those engines.

Match Engine

To customize matching phase go to the "Engines" preference page.

Configure registered matching engine

Some of the registered Matching engines could be configured. If so, an extra panel will be displayed on the left part of the preference page when the Match engine is selected.

Matching strategy for default match engine

The matching strategy of the default match engine can be configured.

Basically, you can choose to use either a strategy based on object identifiers or a strategy based on object content or both.

Enable/Disable Match Engines

Additional Match Engines can be contributed through EMF Compare's extension point (see Override Match Engine). They can be enabled or disabled from the preference page.

For other engines

To customize one of the other phase, go to the "Engines" preference page.

Choose the default engine

On this tab you can select which engine will be used by the comparison process. To do so, check the engine you want to define as default.

Post processors customization

Result of each phase of the comparison process (see Comparison process) can be refined thanks to post processors.

More information:

To customize those post-processors go to the related preference page.

On this page you will find all registered post processors. They have been sorted by ordinal (top element of the list will be executed first). To enable or disable any post processor simply check or uncheck each of them. Unchecked post processors will not be triggered during later comparisons.

Model Resolvers

For each comparison, EMF Compare needs to define which resources are about to be compared. This scope is called the logical model (see Logical Model). Model resolvers are used to define strategies to build this logical model.

To customize the model resolution behavior go to the "Resolution strategy" preference page.

  1. Open preferences: Window -> Preferences
  2. Open "Resolution strategy" preference page: EMF Compare > Resolution strategy

Disable model resolution

EMF Compare can prevent building the logical model. In that case, it will only compare the selected resources. To disable model resolution, uncheck the button called "Enable model resolution".

Choose a strategy

By default, EMF Compare proposes 3 different strategies:

In order to ask EMF Compare to use a specific strategy, first enable the model resolution (if it's not already done) and select it in the combobox.

Other external strategies might be contributed to EMF Compare. In that case it may happen that the selected strategy can not handle a comparison. If it is so, EMF Compare will use the default strategy.

User Interface customization

Colors Customization

You can customize the colors used by EMF Compare to highlight differences in the user interface.

  1. Open preferences: Window -> Preferences
  2. Go to Colors and Fonts preferences: Select -> General -> Appearance -> Colors and Fonts
  3. Open the EMF Compare Category.
  4. Select the color you want to customize and click and edit to pick a new color. Your editor will now use your new colors.

Filters

You have already been explained how to use filters to hide or display differences in EMF Compare UI (see Toolbar). This chapter teaches you how to customize filter default activation.

First open the filters preference page:

The first panel (1) is used to define which filters should be activated by default. Checked elements will be activated for later comparisons. Of course, only filters that can handle the comparison will be activated (for further explanations see Add you own filter).

The second panel (2) is used to define the synchronization behavior between the filters selection in UI and the preferences. The combobox in the preference page has 3 distinct values:

Groups

You have already been explained how to use groups to gather differences in EMF Compare UI (see Toolbar). This chapter teaches you how to customize the default activated group in EMF Compare.

First open the Groups preference page:

This page is divided in two tabs. The first tab handles 2-way comparisons and the second tab handles 3-way comparisons. Each tab contains two panels:

The top panel (1) is used to define the default group. EMF Compare uses an ordered list of groups to determine which group should be the default one. The first group in this list that can handle the comparison is chosen as default group. To change it, simply put the desired group in top of the list. To do so, use the up and down buttons located on the right side of the panel.

The bottom panel (2) is used to define a synchronization behavior between selected group in UI and the preferences. The combo box lets you choose between 3 different behaviors:

Items providers

In EMF item providers are used to define how elements are displayed (label, icon etc..). They belong to the EMF.Edit framework. Item providers are generally contributed to EMF however it can happen that some of them are directly contributed to EMF Compare. In general, it's done if you want to customize the way elements are displayed in EMF Compare without impacting other editors. If you go to the preferences of EMF Compare you will find a page named "Item providers".

In this page, you will find all item providers that have been directly contributed to EMF Compare. Some elements are displayed in grayed meaning that can not be disabled. In our example you can see that "Notation item provider" is grayed. Indeed disabling it would produce incomprehensible results in EMF Compare UI on diagram comparisons. That's why its provider decided to prevents user from disabling it. All other elements can be enabled/disabled using the checkbox on the left of each label. For example the two other item providers can be disabled. If you want to know what an item provider is for, you can select it and a short description will appear in the "Description" field. For example, if you select "Stereotyped element item provider" you would read "This provider displays stereotyped elements like they were a new kind of UML element (it uses stereotype's icon and custom label)". This one can be disabled since without it a comparison result in EMF Compare UI would still be understandable for a user.

Features

Grouping Differences

This feature allows you to group differences together in the structural view according to a set predicate. By default, EMF Compare provides four distinct grouping strategies :

Default
Do not try and group differences together, display them as they were detected.

By Kind
Group differences by their kind ( additions, deletions, moves, changes).

By Side
Group differences according to their side: left or right and a special group regrouping differences in conflicts with other differences together. This grouping strategy is display by default in case of a 3-way comparison.

By Resource
Group differences according to their resource: useful when more than two resources involved in comparison and/or resources are split into fragments.

PENDING UPDATE, this is a demo displaying EMF Compare 1.3 Demo

New grouping strategies can be provided to EMF Compare through extension points. See Add your own group section in developer guide for further details.

Filtering Differences

This features allows you to filter differences out of the structural view according to a set predicate. By default, EMF Compare provides four distinct filters :

Pseudo conflicts differences
Filter out all pseudo conflicts differences (only in case of a 3-way comparison). Enabled by default.
Identical elements
Filter out all identical elements (elements with no differences). Enabled by default.
Empty Resource Mappings
Filter out all resource mappings with no differences from the view. Enabled by default.
Cascading differences
Filter out all differences that are contained under differences (except when in conflict). Enabled by default.

PENDING UPDATE, this is a demo displaying EMF Compare 1.3 Demo

New filters can be provided to EMF Compare through extension points. See Add your own filter section in developer guide for further details.

Handling Conflicts

When a 3-way comparison has conflicts, all differences involved in the same conflict are grouped under a Conflict node.

In the following case, the Employee Green has his manager reference in conflict. The left side of the comparison shows that the manager of the Employee Green is the employee Smith while the right side side shows that the manager is the Employee Johnson. The consequences of a merge from right to left of the selected difference are displayed.

When the left side difference Employee Smith [ manager changed ] is selected in the top panel, the right side difference Employee Johnson [ manager changed ] is highlighted in red, that means if the the left side difference Employee Smith [ manager changed ] is merged from right to left, then it will be impossible to merge the right side difference Employee Johnson [ manager changed ] from left to right.

After the merge of the left side difference from right to left Employee Smith [ manager changed ], the right side difference Employee Johnson [ manager changed ] is not "mergeable" from left to right anymore, it has been merged from right to left automatically.

Text Attribute Comparison

In case of differences made on String-typed attributes, specifics actions are available in the top-right of the content viewer panel.

  1. Allows to merge all changes of the current difference.
  2. Allows to merge the current change.
  3. Allows to move to the next/previous textual difference (in case of multi-valuated String-typed attributes).
  4. Allows to move to next/previous change in the current textual difference.

PENDING UPDATE, this demo displays EMF Compare 1.3 Demo

Graphical Comparison

EMF compare provides the ability to compare models with Papyrus graphical modeler (GMF Diagrams). To get the graphical comparison, the EMF Compare Papyrus integration feature and Papyrus have to be installed. The graphical comparison will be launched if you compare diagrams files (.di), or if you compare models that have diagrams associated in the same folder. In the same way as the semantic model comparison, the graphical model comparison uses the same color coding, to distinguish incoming and outgoing changes, and conflicts. To put in relief the graphical differences, some decorators are used:

The color of the concerned decorators are highlighted on selection of the difference.

In the following example, a 3-way comparison is run with UML class diagrams. We can see that a Shape associated to a semantic uml class named A has been added on the left side of the comparison. After selected the difference in top panel, we can see the concerned elements in down panels. In the left part, the Shape A is highlighted in gray because it is an incoming change. In the right part, a phantom is drawn at the place the Shape should be after merging from right to left.

About phantoms (place-holders):

To ease their readability, in some cases, their context have to be displayed:

They are drawn as:

Here is an example of nested phantom:

Have a look on the following demos :

PENDING update videos

Demo : Comparing Ecore files with diagrams

Demo : Comparing UML files with diagrams

Logical Model

EMF Compare does not act simply on the selected files, but on their whole logical model (a given model can be split through multiple files through EMF control action). Thanks to that, if you try and compare a model file that reference other model files, the comparison will still be able to take these "other" files into account. For example, if you try and compare a genmodel file (that depends on its underlying ecore file) :

EMF Compare will actually consider both files when comparing :

PENDING UPDATE Demo

UML Specialization

A specific work has been done with EMF Compare for UML. It consists in an additional filter named UML refined elements. This filter is active by default when a comparison involves UML resources.

The filter groups UML consistent differences together in one difference. For example, a UML association is modeled by an association element and several sub-elements:

If EMF Compare detects a change on an element of type association, it will group all changes on the sub-elements of the association to the association difference. The goal of this filter is to ease the merge of differences. Indeed, all you have to do is to merge the association difference and it will merge all the sub-differences with it.

Here is the comparison of two UML model, one with an association (the left side), another without (the right side). The UML refined elements filter has been deactivated:

We can see a lot of differences. The same comparison with the UML refined elements filter activated:

PENDING

Demo : Specific support to encapsulate profiles and stereotypes diffs

Logical Model View

EMF Compare does not act simply on the selected files, but on their whole logical model (a given model can be split through multiple files through EMF control action). Thanks to that, if you try and compare a model file that reference other model files, the comparison will still be able to take these "other" files into account. For example, if you try and compare a genmodel file (that depends on its underlying ecore file), then both files will be taken into account for the comparison.

For more details about the logical model, please visit the Logical model page.

The EMF compare Logical Model View allows to see, for a given model (or set of models), the resulting logical model computed by EMF Compare.

The view is accessible from Window > Show View > Other ... > EMF Compare > Logical Model View.

When you click on a model in the Package Explorer view or the Project Explorer view, or the focus is on an opened model editor, then the Logical Model view shows this model and all models linked with this one.

While computing the logical model for a given model, the view shows the progression of computing.

Toolbar

1. The button Link with Editor and Selection synchronize the Logical Model View to the active editor or the selected element in the Package Explorer View.

2. The button View Menu

Contextual Menu

A contextual menu is accessible on each item displayed in the view. Through this menu, you will able to open the item selected, access to its properties, compare it, etc...

Known Bugs and Limitations

Project names and location

Project names should match their location

Cause

If you need to compare models that:

Due to Bug 354801, we cannot properly support models that are located in Eclipse projects which identifier is distinct from their containing folder, case included. For example, if you have a project named EcoreModels, it must be contained in a folder named EcoreModels. Any other name, even if changing only the case, such as ecoreModels, will cause issues when comparing fragmented models (or any model which references another).

Note that this only applies to comparisons launched from within Eclipse, which would trigger the opening of the EMF Compare user interface.

Observed Symptoms

Symptoms vary, but they often include a NullPointerException somewhere in EMFSynchronizationModel such as :

Caused by: java.lang.NullPointerException
at org.eclipse.emf.compare.ide.ui.logical.RevisionedURIConverter.<init>(RevisionedURIConverter.java:108)
at org.eclipse.emf.compare.ide.ui.logical.EMFSynchronizationModel.resolveTraversal(EMFSynchronizationModel.java:464)
at org.eclipse.emf.compare.ide.ui.logical.EMFSynchronizationModel.createSynchronizationModel(EMFSynchronizationModel.java:165)
at org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.EMFCompareStructureMergeViewer.compareInputChanged(EMFCompareStructureMergeViewer.java:258)

Models out of the workspace

The models should be imported within the workspace

Cause

Trying to compare models that are not present in the current Eclipse workspace from either the Git repositories perspective, or from the Git Staging view.

Note that this only applies to comparisons launched from within Eclipse, which would trigger the opening of the EMF Compare user interface.

Observed Symptoms

Symptoms are mostly the same here as they would be with the limitation mentioned above regarding project names, and they usually include the same NullPointerException:

Caused by: java.lang.NullPointerException
at org.eclipse.emf.compare.ide.ui.logical.RevisionedURIConverter.<init>(RevisionedURIConverter.java:108)
at org.eclipse.emf.compare.ide.ui.logical.EMFSynchronizationModel.resolveTraversal(EMFSynchronizationModel.java:464)
at org.eclipse.emf.compare.ide.ui.logical.EMFSynchronizationModel.createSynchronizationModel(EMFSynchronizationModel.java:165)
at org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.EMFCompareStructureMergeViewer.compareInputChanged(EMFCompareStructureMergeViewer.java:258)

Other Materials

Part of EMF Compare Documentation

Version 3.2.0.201411250710