blob: aadca27741de76935ae4802f7390fc207d6ded4c [file] [log] [blame]
<?xml version='1.0' encoding='utf-8' ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Tutorial</title>
<style type="text/css">
.tip {border: 1px solid #090;background-color: #dfd;margin: 20px;padding: 0px 6px 0px 6px;}
.note {border: 1px solid #F0C000;background-color: #FFFFCE;margin: 20px;padding: 0px 6px 0px 6px;}
.info {border: 1px solid #3c78b5;background-color: #D8E4F1;margin: 20px;padding: 0px 6px 0px 6px;}
.warning {border: 1px solid #c00;background-color: #fcc;margin: 20px;padding: 0px 6px 0px 6px;}
.panel {border: 1px solid #ccc;background-color: #FFFFCE;margin: 10px;padding: 0px 6px 0px 6px;}
</style>
<link type="text/css" rel="stylesheet" href="../resources/bootstrap.css"/>
<link type="text/css" rel="stylesheet" href="../resources/custom.css"/>
</head>
<body>
<h1 id="EMF_Compare_.E2.80.94__EMF_Compare_tutorial">EMF Compare — EMF Compare tutorial</h1>
<p>Version 3.1.0.201506080946</p>
<div class="toc">
<h3 class="toc-title">Table of Contents</h3>
<ol style="list-style: none">
<li>
<a href="#Installation">Installation</a>
</li>
<li>
<a href="#Tutorial">Tutorial</a>
<ol style="list-style: none">
<li>
<a href="#Set_up">Set up</a>
<ol style="list-style: none">
<li>
<a href="#Install_custom_ExtLibrary_plugins">Install custom ExtLibrary plugins</a>
<ol style="list-style: none">
<li>
<a href="#Import_the_plugins">Import the plugins</a>
</li>
<li>
<a href="#Launch_runtime_platform">Launch runtime platform</a>
</li>
</ol>
</li>
<li>
<a href="#Associate_EXTLibrary_models_with_EMF_Compare_Content_type">Associate EXTLibrary models with EMF Compare Content type</a>
</li>
</ol>
</li>
<li>
<a href="#Tutorial_2">Tutorial</a>
<ol style="list-style: none">
<li>
<a href="#Context">Context</a>
</li>
<li>
<a href="#Compare_with_history_.282-way_comparison.29">Compare with history (2-way comparison)</a>
<ol style="list-style: none">
<li>
<a href="#Create_a_library_model">Create a library model</a>
</li>
<li>
<a href="#Create_a_new_book">Create a new book</a>
<ol style="list-style: none">
<li>
<a href="#Compare_with_previous_version">Compare with previous version</a>
</li>
<li>
<a href="#Accept_a_difference">Accept a difference</a>
</li>
<li>
<a href="#Reject_a_difference">Reject a difference</a>
</li>
</ol>
</li>
<li>
<a href="#Set_the_name_of_the_book">Set the name of the book</a>
</li>
<li>
<a href="#Change_the_category_of_the_book">Change the category of the book</a>
</li>
<li>
<a href="#Fill_the_library_with_employees">Fill the library with employees</a>
</li>
<li>
<a href="#Set_a_manager">Set a manager</a>
</li>
<li>
<a href="#Change_of_manager">Change of manager</a>
</li>
<li>
<a href="#No_more_manager">No more manager</a>
</li>
<li>
<a href="#Add_borrowers">Add borrowers</a>
</li>
<li>
<a href="#Borrowing_a_book">Borrowing a book</a>
</li>
<li>
<a href="#Create_a_new_library_branch">Create a new library branch</a>
</li>
<li>
<a href="#Move_a_book">Move a book</a>
</li>
<li>
<a href="#Remove_a_book">Remove a book</a>
</li>
</ol>
</li>
<li>
<a href="#Compare_with_repository_.283-way.29">Compare with repository (3-way)</a>
<ol style="list-style: none">
<li>
<a href="#Set_up_2">Set up</a>
<ol style="list-style: none">
<li>
<a href="#Create_a_Git_repository">Create a Git repository</a>
</li>
<li>
<a href="#Share_your_model">Share your model</a>
</li>
<li>
<a href="#Commit_your_changes">Commit your changes</a>
</li>
</ol>
</li>
<li>
<a href="#Create_Scenario_1">Create Scenario 1</a>
<ol style="list-style: none">
<li>
<a href="#Change_the_number_of_pages">Change the number of pages</a>
</li>
</ol>
</li>
<li>
<a href="#Scenario_2:_Conflict">Scenario 2: Conflict</a>
</li>
<li>
<a href="#Scenario_3:_Pseudo_conflict">Scenario 3: Pseudo conflict</a>
</li>
<li>
<a href="#Scenario_4_and_5:_Advanced_conflict">Scenario 4 and 5: Advanced conflict</a>
</li>
<li>
<a href="#Fragment_your_model">Fragment your model</a>
</li>
</ol>
</li>
</ol>
</li>
</ol>
</li>
</ol>
</div>
<p>The aim of this tutorial is to guide you through the basic mechanisms of EMF Compare. The first part of this tutorial will explain you how to set up your environment. The second will help you understand the main differences that EMF Compare detects. The third part will explain you how EGit can interoperate with EMF Compare to compare model from a git repository. </p>
<h2 id="Installation">Installation</h2>
<p>EMF Compare is part of the Eclipse release train. You will find all you need in the eclipse release update of your platform. You can also find newer version on
<a href="http://www.eclipse.org/emf/compare/" title="http://www.eclipse.org/emf/compare/">EMF Compare web site</a> in the download section.
</p>
<p>In order to install EMF Compare:</p>
<ul>
<li>Open the installation wizard : Help &gt; "Install New Software..".</li>
<li>Select the update site from which you want to install EMF Compare. In this example we are using the Luna eclipse release update site:
<ul>
<li>
<a href="http://download.eclipse.org/releases/luna">http://download.eclipse.org/releases/luna</a>
</li>
</ul>
</li>
<li>Check the feature called "EMF Compare IDE UI".</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Install.png"/>
</p>
<ul>
<li>Click on next.</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Install2.png"/>
</p>
<ul>
<li>Click on next.</li>
<li>Read and accept the terms of the license agreement.</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Install3.png"/>
</p>
<ul>
<li>Click on finish.</li>
<li>Once the installation is finished click on "Yes" to restart your platform.</li>
</ul>
<h2 id="Tutorial">Tutorial</h2>
<h3 id="Set_up">Set up</h3>
<h4 id="Install_custom_ExtLibrary_plugins">Install custom ExtLibrary plugins</h4>
<p>This tutorial is based on the well know ExtLibrary meta-model (available from the EMF examples). However for the needs of this tutorial we have customized those plugins. We have:</p>
<ul>
<li>Set up a XMI id serialization to create models in which each element will have a unique id. EMF Compare can compare both models with id and models without id. If no ids are available in the model, EMF Compare uses a heuristic to define if two elements match.</li>
<li>Removed the extendedLibrary content type to explain you how to set it up in your platform.</li>
<li>Added extra icons to make it look prettier.</li>
</ul>
<h5 id="Import_the_plugins">Import the plugins</h5>
<p>Those plugins are hosted in the
<a href="http://git.eclipse.org/c/emfcompare/org.eclipse.emf.compare.git" title="http://git.eclipse.org/c/emfcompare/org.eclipse.emf.compare.git">EMF Compare repository</a>. To import those plugins in your workspace you can follow the
<a href="http://wiki.eclipse.org/EGit/User_Guide#Starting_from_existing_Git_Repositories" title="http://wiki.eclipse.org/EGit/User_Guide#Starting_from_existing_Git_Repositories">EGit tutorial</a>. Here are the main steps:
</p>
<ul>
<li>Clone EMF Compare repository using the following URL (see
<a href="http://wiki.eclipse.org/EGit/User_Guide#Cloning_Remote_Repositories" title="http://wiki.eclipse.org/EGit/User_Guide#Cloning_Remote_Repositories">Clone a repository</a> for further information):
<ul>
<li>
<a href="http://git.eclipse.org/gitroot/emfcompare/org.eclipse.emf.compare.git">http://git.eclipse.org/gitroot/emfcompare/org.eclipse.emf.compare.git</a>
</li>
</ul>
</li>
<li>Import the required plugins into your workspace:
<ul>
<li>Open the "Git Repositories" view (if not already opened): Window &gt; "Show view" &gt; "Other...".</li>
<li>Select "Git Repositories".
<dl>
<dd>
<img border="0" src="../images/EMF_Compare_Tutorial_Git_Repo_View.png"/>
</dd>
</dl>
</li>
<li>Select your clone of EMF Compare repository.</li>
<li>Open the contextual menu and click on "Imports Projects..."
<dl>
<dd>
<img border="0" src="../images/EMF_Compare_Tuto_Import_Project_Wizard.png"/>
</dd>
</dl>
</li>
<li>Select the "tutorial" folder and click on next.
<dl>
<dd>
<img border="0" src="../images/EMF_Compare_Tuto_Import_Project_Wizard1.png"/>
</dd>
</dl>
</li>
<li>Check that the 3 required plugins are checked:
<dl>
<dd>
<dl>
<dd>
<img border="0" src="../images/EMF_Compare_Tuto_Import_Project_Wizard2.png"/>
</dd>
</dl>
</dd>
</dl>
</li>
<li>Click on Finish.</li>
</ul>
</li>
</ul>
<p>In the end you should have your workspace looking like this:</p>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Workspace.png"/>
</p>
<h5 id="Launch_runtime_platform">Launch runtime platform</h5>
<p>Now that you get all you need in your workspace, you need to create a runtime platform. A runtime platform is basically a new eclipse platform built upon your current platform with the new plugins of your workspace included. To do so:</p>
<ul>
<li>Select one of the plugin in your workspace.</li>
<li>Click on the play button in the toolbar
<img border="0" src="../images/EMF_Compare_Tuto_Run_Button.png"/>. If you do not have this button in the toolbar you might need to switch to the Java perspective.
</li>
<li>Select "Eclipse Application" and then click on OK.
<dl>
<dd>
<img border="0" src="../images/EMF_Compare_Tuto_Runtime_Platform.png"/>
</dd>
</dl>
</li>
<li>A new eclipse platform should start. This is your runtime platform.</li>
</ul>
<p>
<b>All the following instructions should be done on the runtime platform.</b>
</p>
<h4 id="Associate_EXTLibrary_models_with_EMF_Compare_Content_type">Associate EXTLibrary models with EMF Compare Content type</h4>
<p>EMF Compare editor is based on the Content types mechanism. Basically, EMF Compare will be used in a comparison if the Content type of the current resource is either one of the following types(or inherits from one of them):</p>
<ul>
<li>XMI content type</li>
<li>Ecore content type</li>
<li>EMF Compare content type</li>
</ul>
<p>You can also use the "Content Types" preference page to associate your model files with EMF Compare content type.</p>
<p>This is the first step of this tutorial. To do so:</p>
<ul>
<li>Open the preference page : Window &gt; Preferences.</li>
<li>Select the "Content Types" preference page: General &gt; Content Types.</li>
<li>Select EMF Compare item.</li>
<li>Click on the "Add..." button.</li>
<li>Write the pattern matching all extlibrary files : "*.extlibrary".</li>
<li>Click on OK.</li>
</ul>
<p>
<img border="0" src="../images/Content_Types_Preference_Page.png"/>
</p>
<p>If you are using the basic EXTLibrary plugins (imported from examples) this step is not mandatory since a content type is already defined and it inherits from the XMI content type. However, those plugins do not generate ids, so we do not recommend you to use them.</p>
<h3 id="Tutorial_2">Tutorial</h3>
<h4 id="Context">Context</h4>
<p>If you have correctly followed the previous steps you should have the following environment:</p>
<ul>
<li>The custom ExtLibrary meta-model installed in your runtime</li>
<li>Associated the .extlibrary files with the EMF Compare content type</li>
<li>Using EMF Compare default preferences</li>
</ul>
<h4 id="Compare_with_history_.282-way_comparison.29">Compare with history (2-way comparison)</h4>
<p>Now that everything is set up, we are going to go through all the major differences EMF Compare detects and handles. To do so we will create a library model step by step. Each time that we will modify the library we will compare it with a previous version to see how EMF Compare handles each difference.</p>
<h5 id="Create_a_library_model">Create a library model</h5>
<p>First we need to create our library model. To do so:</p>
<ul>
<li>Create a project with the name "TutorialModel" for example.</li>
<li>Create an extlibrary model:
<ul>
<li>Click on: File &gt; New &gt; Other.</li>
<li>Select EXTLibrary Model.
<dl>
<dd>
<img border="0" src="../images/Create_Extlibrary_Model.png"/>
</dd>
</dl>
</li>
<li>Click on next.</li>
<li>Set its name to "TutorialModel.extlibrary" for example.
<dl>
<dd>
<img border="0" src="../images/Create_Extlibrary_Model_Set_Name.png"/>
</dd>
</dl>
</li>
<li>Click on next.</li>
<li>Select a Library element as root.
<dl>
<dd>
<img border="0" src="../images/Create_Extlibrary_Model_Root_Element.png"/>
</dd>
</dl>
</li>
<li>Click on finish.</li>
</ul>
</li>
</ul>
<p>Your model is now open.</p>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Model_Creation.png"/>
</p>
<h5 id="Create_a_new_book">Create a new book</h5>
<p>We are now going to fill your library with your first book.</p>
<ul>
<li>Select the library element in your opened editor (In this example TutorialModel.extlibrary).</li>
<li>Open the contextual menu.</li>
<li>Select "New Child" &gt; "Book".</li>
<li>Save your model.</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Book_Creation.png"/>
</p>
<h6 id="Compare_with_previous_version">Compare with previous version</h6>
<p>Now that our library contains one book let's compare it with the previous state of our model:</p>
<ul>
<li>Select your model file in project explorer (or package explorer) view.</li>
<li>Open the contextual menu.</li>
<li>Select "Compare With" &gt; "Local History...".</li>
</ul>
<p>
<img border="0" src="../images/Compare_With_Local_History.png"/>
</p>
<p>The history view is now open.</p>
<p>
<img border="0" src="../images/Local_History_View.png"/>
</p>
<p>This view will display each state of the file that Eclipse has saved for you. Each time you will save your model a new entry will appear. The item written in bold is the current version of your file. In the first part of this tutorial you will have to compare the current version of your model with its previous version.</p>
<p>To do so, double click on the entry just below the bold entry.</p>
<p>The EMF Compare editor is now open.</p>
<p>
<img border="0" src="../images/EMF_Compare_Editor_Tuto_New_Book.png"/>
</p>
<p>This comparison is a 2-way comparison. That is to say the comparison is only between 2 inputs (the current version of your file and the previous version from your local history). You will see in the second part of this tutorial that there is also a 3-way comparison.</p>
<p>Let's have a look at the user interface. The tool bar look like this:</p>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Accept_Reject_Toolbar.png"/>
</p>
<p>This toolbar appears when you are in accept/reject mode. This mode is activated when at least one of the inputs is not writable. In our example the current version of your file can be modified whereas the previous version of it cannot (since it is provided by the local history). In this mode you can accept or reject a difference. This is obvious, but the only resource that is going to be modified is the current version of your model.</p>
<p>The top of the editor is filled with the "Structure Merge viewer". In it, you will find a structured representation of all differences that EMF Compare has found.</p>
<p>On the bottom of the editor you have a viewer called "Content viewer". This viewer displays the content of your input models. On the left, it displays the content of the current version of your model. On the right it displays the content of the previous version.</p>
<p>To have a full understanding of the user interface please see
<a href="./../user/user-guide.html#User_Interface_Breakdown" title="./../user/user-guide.html#User_Interface_Breakdown">User Interface Breakdown</a>.
</p>
<p>Now let's have a look at the difference:
<img border="0" src="../images/EMF_Compare_Tuto_New_Book_Difference.png"/>
</p>
<p>On this difference you find some pieces of information:</p>
<ul>
<li>The "+" overlay icon indicates that the difference is an addition (see
<a href="./../user/user-guide.html#Signification_of_icons_associated_with_differences" title="./../user/user-guide.html#Signification_of_icons_associated_with_differences">Signification of icons associated with differences</a> for further information).
</li>
<li>The suffix enclosed in brackets describes the nature of the difference and the name of feature which has been modified. In this case, the difference is an addition in the feature "Stock" (The modified feature is not "books" since it is a derived feature. It is computed from the "real" feature "Stock").</li>
</ul>
<p>
<b>In this tutorial, you should never save the EMF Compare editor except if it is explicitly asked. For the moment, EMF Compare does not allow undoing an action if the model has been saved. Since we are going to go through every possible action we are going to make a lot of undo operations.</b>
</p>
<h6 id="Accept_a_difference">Accept a difference</h6>
<p>First accept the modification we have just created. To do so:</p>
<ul>
<li>Select the difference you want to accept.
<ul>
<li>Click on the difference within the structure merge viewer (top viewer). Double click on it to open the content merge viewer related to this difference.</li>
</ul>
</li>
<li>Click on the accept icon
<img border="0" src="../images/accept_change.gif"/>.
</li>
</ul>
<p>Your editor should look like this:</p>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_New_Book_Difference_Accepted.png"/>
</p>
<p>A new overlay icon has appeared on the difference. It means that the difference has been merged. You can also notice in the content viewer of the current model version that the book isn't framed any more. This also means that the difference has been merged.</p>
<h6 id="Reject_a_difference">Reject a difference</h6>
<p>Let's try to reject the difference:</p>
<ul>
<li>Undo the previous action using the keyboard shortcut (Ctrl+z) or the File menu (Edit &gt; Undo).</li>
<li>Click on the reject icon
<img border="0" src="../images/reject_change.gif"/>.
</li>
</ul>
<p>Your editor should look like this:</p>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_New_Book_Difference_Rejected.png"/>
</p>
<p>The "x" overlay on the difference icon means that it has been rejected. In the content viewer of the current model version the book has disappeared. Indeed, since the modification has been rejected the previous version of this object is used.</p>
<h5 id="Set_the_name_of_the_book">Set the name of the book</h5>
<p>We are now going to set the name of the book we have just created. This will change the value of the attribute "Title" to "Prelude to Foundation".</p>
<ul>
<li>Close the compare editor (without saving).</li>
<li>Open the model editor.</li>
<li>Set the name of the book to "Prelude to Foundation".
<ul>
<li>Select the book.</li>
<li>Display the Properties view: Contextual menu &gt; Show property view.</li>
<li>Fill the title field.</li>
</ul>
</li>
<li>Save.</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Setting_Book_Name.png"/>
</p>
<p>Now let's compare it with previous version (see previous chapter for explanation
<a href="#Compare_with_previous_version">Compare with previous version</a>).
</p>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Book_Name_Comparison.png"/>
</p>
<p>On the difference you see the overlay indicating that this difference is a change. This difference is a set on the feature "Title". If you look on the content viewer of the current version, you will see the new value of the feature whereas in the previous version nothing is displayed.</p>
<p>If you accept the difference you will notice the same effect than in the previous chapter (see
<a href="#Accept_a_difference">Accept a difference</a>).
</p>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Book_Name_Accepted.png"/>
</p>
<p>If you reject the difference the name of the book will be unset since it has not been set in the previous version (see
<a href="#Reject_a_difference">Reject a difference</a>).
</p>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Book_Name_Rejected.png"/>
</p>
<h5 id="Change_the_category_of_the_book">Change the category of the book</h5>
<p>We are going to define that this book is a Science Fiction book. This will change the value of the "Category" feature of the book from its default value "Mystery" to "ScienceFiction".</p>
<ul>
<li>Close the compare editor (without saving).</li>
<li>Open the model editor.</li>
<li>Change the category of the book to ScienceFiction:
<ul>
<li>Select the book.</li>
<li>Open the property view.</li>
<li>Change the value of the "Category" feature.</li>
</ul>
</li>
<li>Save.</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Setting_Book_Category.png"/>
</p>
<p>Now let's compare it with its previous version (see previous chapter for explanation
<a href="#Compare_with_previous_version">Compare with previous version</a>).
</p>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Book_Category_Comparison.png"/>
</p>
<p>On the content viewer of the current version you see the new value of the feature "Category" whereas in the previous version the default value is displayed.</p>
<p>Accept the difference and you obviously see (see
<a href="#Accept_a_difference">Accept the difference</a>):
</p>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Book_Category_Accepted.png"/>
</p>
<p>Reject the difference to set the "Category" feature to its default value (see
<a href="#Reject_a_difference">Reject a difference</a>).
</p>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Book_Category_Rejected.png"/>
</p>
<h5 id="Fill_the_library_with_employees">Fill the library with employees</h5>
<p>To fill your library we are going to add some employees.</p>
<ul>
<li>Close the compare editor (without saving).</li>
<li>Open the model editor.</li>
<li>Create an employee and set last name to Chief.</li>
<li>Create an employee and set last name to Master.</li>
<li>Create an employee and set last name to Employee.</li>
<li>Save.</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Fill_Employees.png"/>
</p>
<p>For this step we are not going to compare with the previous version of the model. EXTLibrary stores persons in feature maps. For the moment feature maps are not correctly handled by EMF Compare. Features map comparison will be integrated for the next Eclipse release (Mars in 2015).</p>
<h5 id="Set_a_manager">Set a manager</h5>
<p>Let's set the manager of "Employee" to "Chief". This will set the reference "Manager" of "Employee" to "Chief".</p>
<ul>
<li>Select the employee "Employee".</li>
<li>Open the Properties view.</li>
<li>Make the "Manager" feature point to "Chief".</li>
<li>Save.</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Set_Manager_Chief.png"/>
</p>
<p>Now let's compare it with its previous version (see previous chapter for explanation
<a href="#Compare_with_previous_version">Compare with previous version</a>).
</p>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Set_Manager_Chief_Comparison.png"/>
</p>
<p>You can notice the change in the content viewer. However it is slightly different from the previous comparison. In the content viewer, you now have a new top image.</p>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Top_Image_Reference.png"/>
</p>
<p>It means that the current difference is a non containment reference. If you look back to
<a href="#Compare_with_previous_version">Compare with previous version</a> the content viewer is not the same since the feature involved was a containment reference.
</p>
<p>Accept this difference and you will see the same type of result than
<a href="#Accept_a_difference">Accept a difference</a>.
</p>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Set_Manager_Chief_Accepted.png"/>
</p>
<p>Reject this difference and you will see the same type of result than
<a href="#Reject_a_difference">Reject a difference</a>.
</p>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Set_Manager_Chief_Rejected.png"/>
</p>
<h5 id="Change_of_manager">Change of manager</h5>
<p>Let's say "Employee" has a new job and so he has a new manager. We have to change the feature "Manager" from "Chief" to "Master".</p>
<ul>
<li>Close EMF Compare editor (without saving).</li>
<li>Open the model editor.</li>
<li>Select the employee "Employee".</li>
<li>Set the feature "Manager" to "Master".</li>
<li>Save.</li>
<li>Compare with previous.</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Change_Manager_Master_Comparison.png"/>
</p>
<p>Accept the change to mark the difference as merged. Reject it to reset the manager of "Employee" to "Chief".</p>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Change_Manager_Master_Reject.png"/>
</p>
<h5 id="No_more_manager">No more manager</h5>
<p>Let's say that "Employee" has reached the top of the command chain. That is to say he has no more manager.</p>
<ul>
<li>Close EMF Compare editor (without saving).</li>
<li>Open the model editor.</li>
<li>Select the employee "Employee".</li>
<li>Unset the feature "Manager" of "Employee".
<ul>
<li>Open Properties view.</li>
<li>Select "Manager" field.</li>
<li>Use the "Restore Default Value" button in the toolbar.</li>
</ul>
</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Unset_Employee_Manager.png"/>
</p>
<ul>
<li>Save.</li>
<li>Compare with previous.</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Unset_Employee_Manager_Comparison.png"/>
</p>
<p>The difference is the opposite of
<a href="#Set_a_manager">set a manager</a>.
</p>
<ul>
<li>Accept the difference to get:</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Unset_Employee_Manager_Comparison_Accepted.png"/>
</p>
<ul>
<li>Reject the difference to get:</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Unset_Employee_Manager_Comparison_Rejected.png"/>
</p>
<h5 id="Add_borrowers">Add borrowers</h5>
<p>Let's open the gates of your library to the public. We are going to add borrowers to this library.</p>
<ul>
<li>Close EMF Compare Editor (without saving).</li>
<li>Open the model editor.</li>
<li>Add a new borrower named Will Graham.</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Fill_Borrowers.png"/>
</p>
<p>For the same reason explained in
<a href="#Fill_the_library_with_employees">Fill the library with employees</a> we are not going to compare the model this time.
</p>
<h5 id="Borrowing_a_book">Borrowing a book</h5>
<p>We are going to use your newly created borrower by making him borrow "Prelude to foundation".</p>
<ul>
<li>Open the model editor.</li>
<li>Select the borrower "Graham".</li>
<li>Add "Prelude to Foundation" to the feature "Borrowed" in the Properties view.</li>
<li>Save.</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Graham_Borrows_Book_Setting.png"/>
</p>
<ul>
<li>Compare with previous.</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Graham_Borrows_Book_Comparison.png"/>
</p>
<p>In this comparison you can notice two differences:
<img border="0" src="../images/EMF_Compare_Tuto_Graham_Borrows_Book_Comparison_Borrowers_Diff.png"/> and
<img border="0" src="../images/EMF_Compare_Tuto_Graham_Borrows_Book_Comparison_Borrowed_Diff.png"/>.
</p>
<p>EMF Compare displays two differences whereas you have only made one modification in your model. The explanation is within the structure of the EXTlibrary metamodel. If you look at the feature "borrowed" in extlibrary.ecore you will see that the EOpposite field is set to "borrowers : Borrower".</p>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Graham_Borrows_Book_Comparison_EOpposite.png"/>
</p>
<p>This means that each time you add/remove a book to a borrower EMF will automatically add/remove the borrower to the "borrower" feature of the book (and the other way around). Modifying one feature will modify the other. It explains why EMF Compare sees two differences.</p>
<p>Now you may wonder what happens when you accept one of the differences? EMF Compare will give you a hint on this matter. First notice the consequences preview button
<img border="0" src="../images/EMF_Compare_Tuto_Consequences_Preview_Button.png"/>. It can either have its icon set to
<img border="0" src="../images/accept.gif"/> for "Accept preview mode" or
<img border="0" src="../images/reject.gif"/> for "Reject preview mode".
</p>
<p>When the "Accept preview mode" is activated (
<img border="0" src="../images/accept.gif"/>), EMF Compare will help you understand the consequences of accepting the current selected difference. Let's try it.
</p>
<ul>
<li>Activate the "Accept preview mode" (
<img border="0" src="../images/accept.gif"/>).
</li>
<li>Select "Borrower Graham [borrowers add]" difference.</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Graham_Borrows_Book_Comparison.png"/>
</p>
<p>Notice that the "Book Prelude to Foundation [borrower add]" difference is highlighted in green. This means that accepting the current difference will automatically accept this difference too. Those two differences are linked by an "Equivalence" element meaning that merging one is equivalent to merging the other. You can reproduce the same behavior by selecting the difference "Book Prelude to Foundation [borrower add]" instead of "Borrower Graham [borrowers add]".</p>
<ul>
<li>Accept the difference and check the result.</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Graham_Borrows_Book_Comparison_Accepted.png"/>
</p>
<p>Both differences have been accepted.
Now let's try to reject the difference. </p>
<ul>
<li>Undo the previous merge (Ctrl+z).</li>
<li>Switch to the reject preview mode(
<img border="0" src="../images/reject.gif"/>).
</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Switch_Reject_Preview_Mode.png"/>
</p>
<ul>
<li>Select one difference.
<ul>
<li>Notice that the other difference is also highlighted in green. Since the two differences are "equivalent" both preview modes show the same consequences. You will see later in another use case that each preview mode can show different consequences.</li>
</ul>
</li>
<li>Reject the difference.</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Graham_Borrows_Book_Comparison_Rejected.png"/>
</p>
<p>Both differences have been rejected.</p>
<h5 id="Create_a_new_library_branch">Create a new library branch</h5>
<p>Now that your library is growing, let's create a new branch in your library. This new library will be affiliated to the main entity but will have an independent life.</p>
<ul>
<li>Close EMF Compare Editor (without saving).</li>
<li>Open the model editor.</li>
<li>Create a new library under your main library.</li>
<li>Create a new book within the new library called "1984".</li>
<li>Save.</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_New_Library_Setting.png"/>
</p>
<ul>
<li>Compare with previous.</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_New_Library_Comparison.png"/>
</p>
<p>EMF Compare displays only one difference whereas you have made two modifications. You have created one sub library and one book. There must be a connection between those two differences... Indeed without the library it's impossible to create the book "1984" since it is included in the new library. For clarity purposes EMF Compare only shows one difference and hides the other one.</p>
<ul>
<li>Accept the difference.</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_New_Library_Comparison_Accepted.png"/>
</p>
<p>EMF Compare has accepted both differences. It has created the new library and the new book. On the contrary let's try to reject the difference.</p>
<ul>
<li>Undo the previous action (Ctrl+z).</li>
<li>Reject the difference.</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_New_Library_Comparison_Rejected.png"/>
</p>
<p>EMF Compare rejects both differences.</p>
<p>In some use cases it can be useful to display both differences. For example if we would like to accept the creation of the library but reject the creation of the book. To do so, you have to use the filter button ( see
<a href="./../user/user-guide.html#Filtering_Differences" title="./../user/user-guide.html#Filtering_Differences">Filtering Differences</a> for further information).
</p>
<ul>
<li>Undo the previous action (Ctrl+z).</li>
<li>Deactivate "Cascading difference" filter.</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_New_Library_Comparison_Cascading_Filter.png"/>
</p>
<ul>
<li>Click on "No". It tells EMF Compare not to remember your choice for subsequent comparisons.</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_New_Library_Comparison_Cascading_Filter_Popup.png"/>
</p>
<p>Once the filter has been deactivated you will see both differences. Now you can separately merge each difference.</p>
<ul>
<li>Activate "Accept preview mode" (
<img border="0" src="../images/accept.gif"/>).
</li>
<li>Select the book difference "Book 1984 [stock add]".</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_New_Library_Comparison_Cascading_Filter2.png"/>
</p>
<p>Notice that the library difference is highlighted. Indeed, merging the book difference will necessarily merge the library difference. </p>
<ul>
<li>Switch to "Reject preview mode" (
<img border="0" src="../images/reject.gif"/>).
</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_New_Library_Comparison_Cascading_Filter3.png"/>
</p>
<p>In this mode the other difference is not highlighted. Indeed, you can reject the creation of the book without rejecting the creation of the library. In the same way, selecting the library difference while "Reject preview mode" is activated will highlight the book difference. If the library does not exist then the book can also not exist.</p>
<ul>
<li>Activate "Reject preview mode" (
<img border="0" src="../images/reject.gif"/>).
</li>
<li>Select the library difference.</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_New_Library_Comparison_Cascading_Filter_Reject_Mode.png"/>
</p>
<h5 id="Move_a_book">Move a book</h5>
<p>In order to fill the new library we are going to give it one book from the main library. </p>
<ul>
<li>Close EMF Compare editor (without saving).</li>
<li>Open the model editor.</li>
<li>Move "Prelude to Foundation" to the new branch library (using drag and drop).</li>
<li>Save.</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_New_Library_Move_Setting.png"/>
</p>
<ul>
<li>Compare with previous.</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_New_Library_Move_Comparison.png"/>
</p>
<p>With this example we have introduced a new type of change: "moving an element". This means the element already existed in the previous version but was located in a different place. In the content viewer you can see the location of this element in the current and previous versions of your model.</p>
<ul>
<li>Accept the change to mark the difference as merged.</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_New_Library_Move_Accepted.png"/>
</p>
<ul>
<li>Undo the previous action (Ctrl+z).</li>
<li>Reject the difference to move back the element to its original location.</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_New_Library_Move_Rejected.png"/>
</p>
<h5 id="Remove_a_book">Remove a book</h5>
<p>After an accident the book "1984" has to be removed from the shelves.</p>
<ul>
<li>Close EMF Compare editor (without saving).</li>
<li>Open the model editor.</li>
<li>Delete the book "1984".</li>
<li>Save.</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Remove_Book_Setting.png"/>
</p>
<ul>
<li>Compare with previous.</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Remove_Book_Comparison.png"/>
</p>
<p>This kind of change is the opposite of an addition. </p>
<ul>
<li>Accept the change to delete the book.</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Remove_Book_Accepted.png"/>
</p>
<ul>
<li>Undo the previous action (Ctrl+z).</li>
<li>Reject the change to add the book back into the library.</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Remove_Book_Rejected.png"/>
</p>
<h4 id="Compare_with_repository_.283-way.29">Compare with repository (3-way)</h4>
<h5 id="Set_up_2">Set up</h5>
<p>In this part of the tutorial we will continue building our model. The only difference is that we are going to create different scenarios for each new modification. To do this we need a tool called Git. It is a free and open source distributed version control system. In Eclipse world we are going to talk about
<a href="http://www.eclipse.org/jgit/" title="http://www.eclipse.org/jgit/">JGit</a> and
<a href="http://www.eclipse.org/egit/" title="http://www.eclipse.org/egit/">EGit</a>. JGit is a java implementation of Git. EGit is the integration of JGit in Eclipse.
</p>
<p>Attention: Remove the book "Prelude to Foundation" from the "Borrowed" feature of borrower "Graham" before continuing. The following examples assume this relation is not set!</p>
<h6 id="Create_a_Git_repository">Create a Git repository</h6>
<p>First of all we need a Git repository. You can either use a clone of an existing Git repository or create your own local Git repository. We have chosen the second solution for this tutorial.</p>
<ul>
<li>Open the "Git Repositories" view (if not already open): Window &gt; "Show view" &gt; "Other...".
<ul>
<li>Select "Git Repositories".
<dl>
<dd>
<img border="0" src="../images/EMF_Compare_Tutorial_Git_Repo_View.png"/>
</dd>
</dl>
</li>
</ul>
</li>
<li>Then click on the new repository button
<img border="0" src="../images/EMF_Compare_Tuto_Create_Git_Repo_Button.png"/>.
</li>
<li>Set the location of your new repository. If prompted give it a name.
<dl>
<dd>
<img border="0" src="../images/EMF_Compare_Tuto_Create_Git_Repo_Wizard.png"/>
</dd>
</dl>
</li>
<li>Click on finish.
<dl>
<dd>
<img border="0" src="../images/EMF_Compare_Tuto_Repository_View.png"/>
</dd>
</dl>
</li>
</ul>
<h6 id="Share_your_model">Share your model</h6>
<p>Now that your repository is ready. Let's put your model in it.</p>
<ul>
<li>Select the project holding your model.</li>
<li>Open the contextual menu: "Team" &gt; "Share project...".
<dl>
<dd>
<img border="0" src="../images/EMF_Compare_Tuto_Share_Project.png"/>
</dd>
</dl>
</li>
<li>Select "Git" and click next.
<dl>
<dd>
<img border="0" src="../images/EMF_Compare_Tuto_Share_Project_Wizard.png"/>
</dd>
</dl>
</li>
<li>Choose the repository you previously created and click on finish.
<dl>
<dd>
<img border="0" src="../images/EMF_Compare_Tuto_Share_Project_Wizard2.png"/>
</dd>
</dl>
</li>
</ul>
<h6 id="Commit_your_changes">Commit your changes</h6>
<p>Your project has now been moved into the repository. However your work has not been committed yet. Committing a model is like taking a snapshot of it and saving it for later (see
<a href="http://wiki.eclipse.org/EGit/User_Guide#Committing_Changes" title="http://wiki.eclipse.org/EGit/User_Guide#Committing_Changes">Commiting Changes</a> for further information). To do so:
</p>
<ul>
<li>Select the project holding your model.</li>
<li>Open the contextual menu (right click): "Team" &gt; "Commit...".</li>
<li>Enter a message for this commit describing what has been done. For this example "First commit." will do.</li>
<li>Select the files you want to commit. In our example select all files.
<dl>
<dd>
<img border="0" src="../images/EMF_Compare_Tuto_First_Commit.png"/>
</dd>
</dl>
</li>
<li>Click on the commit button.</li>
</ul>
<p>Your project has just been committed into your repository.
Let's have a look at your repository and its history.</p>
<ul>
<li>Select your repository in the "Git Repositories" view.</li>
<li>Open the "History" view:
<ul>
<li>Open the contextual menu by right clicking on the repository.</li>
<li>Choose "Show In" &gt; "History"</li>
</ul>
</li>
</ul>
<p>It should look like this:
<img border="0" src="../images/EMF_Compare_Repository_State1.png"/>
</p>
<p>Expand your repository tree in the "Git Repositories" view. In it you can see a folder named "Local" located within "Branches". This folder contains all the branches of your Git repository. In this example each branch will represent a scenario of your model. You can notice that your repository has already a "master" branch. This is your main scenario.</p>
<p>In the history view you can see the graph of all your commits. Currently the only entry available is the first commit you have made earlier. To better understand the changes that we are going to make in the repository, we advice you to click on the "Synchronize" button (
<img border="0" src="../images/EMF_Compare_Tuto_Sync_Button.png"/>) and on the "Show all branches" button (
<img border="0" src="../images/EMF_Compare_Tuto_Show_All_Branches_Button.png"/>). This will give you a global point of your repository.
</p>
<h5 id="Create_Scenario_1">Create Scenario 1</h5>
<p>Let's create our first scenario. To do so:</p>
<ul>
<li>Select the branch within the "Git Repositories" view that will be used as start point your new branch. In this case: master.</li>
<li>Open the contextual menu: "Create Branch...".</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Create_New_Branch.png"/>
</p>
<ul>
<li>Set its name to "Scenario1". The button "Checkout new branch" must be checked.</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Create_New_Branch_Wizard.png"/>
</p>
<ul>
<li>Click on finish.</li>
</ul>
<p>You have just created a new scenario that will use the last commit from the master branch as starting point.</p>
<h6 id="Change_the_number_of_pages">Change the number of pages</h6>
<p>You have now two branches in your repository. Let's modify our model to write our first scenario.</p>
<ul>
<li>Open the model editor.</li>
<li>Select the book "Prelude to Foundation".</li>
<li>Open the "Properties" view.</li>
<li>Change the value of the field "Pages" to 374.</li>
<li>Save.</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Scenario1_Setting.png"/>
</p>
<ul>
<li>Compare this model with the last commit in your repository:
<ul>
<li>Select your model file.</li>
<li>Open the contextual menu: "Compare With" &gt; "Head Revision".</li>
</ul>
</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Scenario1_Comparison.png"/>
</p>
<p>This is a comparison between the current version of your model and the snapshot that you have committed earlier. Let's save this version. To do so we are going to commit it. Follow the steps as described in
<a href="#Commit_your_changes">Commit your changes</a>:
</p>
<ul>
<li>Select the project holding your model.</li>
<li>Open the contextual menu: Team &gt; "Commit...".</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Scenario1_Commit.png"/>
</p>
<ul>
<li>Enter the commit message: "Set page number to 374".</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Scenario1_Commit_Message.png"/>
</p>
<ul>
<li>Click on commit.</li>
</ul>
<h5 id="Scenario_2:_Conflict">Scenario 2: Conflict</h5>
<p>Let's create a different scenario. Follow the step described in
<a href="#Create_Scenario_1">Create Scenario 1</a> to create a new scenario called "Scenario2" from the master branch.
</p>
<ul>
<li>Click on the master branch in the "Git Repositories" view.</li>
<li>Open the contextual menu: "Create Branch...".</li>
<li>Set the name of the new branch to "Scenario2".</li>
<li>Click on finish.</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Scenario2_Creation.png"/>
</p>
<p>In this scenario we are going to set the number of pages of "Prelude to Foundation" to 375.</p>
<ul>
<li>Refresh the model editor by double clicking on the "TutorialModel.extlibrary".</li>
<li>Set the number of page of "Prelude to Foundation" to 375 (see
<a href="#Change_the_number_of_pages">Change the number of pages</a> for further information)
</li>
<li>Save.
<dl>
<dd>
<img border="0" src="../images/EMF_Compare_Tuto_Scenario2_Setting.png"/>
</dd>
</dl>
</li>
<li>Commit your changes (see
<a href="#Commit_your_changes">Commit your changes</a> for further information).
</li>
<li>Set the commit message to "Set page number to 375."</li>
<li>Compare your model with "Scenario1":
<ul>
<li>Select the model file.</li>
<li>Open the contextual menu: "Compare with" &gt; "Commit...".
<dl>
<dd>
<img border="0" src="../images/EMF_Compare_Tuto_Scenario2_Compare_With_Commit.png"/>
</dd>
</dl>
</li>
<li>Select the commit that holds the "Scenario1" tag.
<dl>
<dd>
<img border="0" src="../images/EMF_Compare_Tuto_Scenario2_Compare_With_Commit2.png"/>
</dd>
</dl>
</li>
</ul>
</li>
</ul>
<p>You should now have an EMF Compare editor open.</p>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Scenario2_Comparison.png"/>
</p>
<p>The first thing to understand is that this comparison is a 3-way comparison. This means that EMF Compare has used 3 inputs to compute the differences. The first one (in the bottom left) is the local version of your model ("Scenario2"). The second one (in the bottom right) is the version of your model from "Scenario1". And the third one is a common ancestor of the two other versions. The history view gives a picture of the situation.</p>
<ul>
<li>Have a look on the history view of your repository.</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Scenario2_Common_Ancestor.png"/>
</p>
<p>Both scenario 1 and 2 used the master branch as starting point. This is why it has being used as common ancestor. We will see later on this tutorial how EMF Compare uses this third input. You can display its content in EMF Compare by clicking on the "Show Ancestor Pane" button (
<img border="0" src="../images/EMF_Compare_Tuto_Show_Ancestor_Button.png"/>).
</p>
<p>
<img title=" Common Ancestor 2" alt=" Common Ancestor 2" border="0" src="../images/EMF_Compare_Tuto_Scenario2_Common_Ancestor2.png "/>
</p>
<ul>
<li>Let's have a look at the differences.</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Scenario2_Conflict_Differences.png"/>
</p>
<p>You can notice a new type of difference: conflicts. Indeed in Scenario1 we set the number of pages to 374 whereas we set it to 375 in Scenario2. EMF Compare is telling us that it cannot be both. If you select one of the difference you will see that the other is highlighted in red. This means that if you merge this difference EMF Compare will not be able to merge the other one.</p>
<p>We are now going to see what will be the impact of accepting or rejecting each difference.</p>
<ul>
<li>Select the difference named "375 [page changed]".</li>
<li>Accept the difference.</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Scenario2_Accept_375.png"/>
</p>
<p>In this case EMF Compare has accepted the selected difference and rejected the other one since they cannot be accepted simultaneously. Let's try to reject this difference.</p>
<ul>
<li>Undo the previous action (Ctrl+z).</li>
<li>Switch to "Reject preview mode" (
<img border="0" src="../images/reject.gif"/>).
</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Scenario2_Reject_Preview_Mode.png"/>
Notice that nothing is highlighted in red. It seems that rejecting this difference has no consequence on other differences. Let's find out.
</p>
<ul>
<li>Reject the difference named "375 [page changed]".</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Scenario2_Reject_375.png"/>
</p>
<p>In this case EMF Compare only rejected the current difference. When you look at the value of the attribute you will see that the number of page has been set to 100. This value is the value of the same attribute in the common ancestor model (see picture "Common Ancestor 2"). In 3-way comparison you can either accept the version of an attribute from one of the two input version (Scenario 1 or Scenario 2) or return the version to its common ancestor value (master).</p>
<p>Obviously you can do the same actions on the difference named "374 [page changed]". It will:</p>
<ul>
<li>Set the value of the attribute to 374 and reject the other difference if you accept it.</li>
<li>Set the value of the attribute to 100 if you reject it.</li>
</ul>
<p>Note that after rejecting one scenario you still have to handle the remaining difference. Depending on if you accept or reject it, the final value of the attribute will be the one of the common ancestor or the one of the remaining scenario.</p>
<h5 id="Scenario_3:_Pseudo_conflict">Scenario 3: Pseudo conflict</h5>
<p>In the previous chapter you have seen how EMF Compare handles two conflicting changes between two scenarios. In this chapter we are going to see how it handles two changes that are semantically the same. Let's create a third scenario:</p>
<ul>
<li>Create a new branch named "Scenario3" from the master branch (see
<a href="#Create_Scenario_1">Create Scenario 1</a> to see how to create a new scenario).
</li>
<li>Open the model editor.</li>
<li>Set the number of pages of "Prelude to Foundation" to 375 (see
<a href="#Scenario_2:_Conflict">Scenario 2</a> for further explanation).
</li>
<li>Save.</li>
<li>Commit your changes (see
<a href="#Commit_your_changes">Commit your changes</a>). Set the commit message to "Set page number to 375".
</li>
<li>Compare this version with Scenario2 :
<ul>
<li>Select your model file.</li>
<li>Open the contextual menu: "Compare with" &gt; "Branch, Tag or Reference...".
<dl>
<dd>
<img border="0" src="../images/EMF_Compare_Tuto_Scenario3_Compare_With_Branch.png"/>
</dd>
</dl>
</li>
<li>Select "Scenario2".
<dl>
<dd>
<img border="0" src="../images/EMF_Compare_Tuto_Scenario3_Compare_With_Scenario2.png"/>
</dd>
</dl>
</li>
<li>Click on Compare.</li>
</ul>
</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Scenario3_Comparison.png"/>
</p>
<p>At first glance it seems that no difference was detected. This is not really surprising since the two input models are semantically identical. However you will see that EMF Compare has done some work:</p>
<ul>
<li>Deactivate the "Pseudo Conflict" filter.</li>
<li>Handle the filter popup. Select "Yes" if you want to deactivate the "Pseudo conflict" filter by default for all subsequent comparisons. Select "No" if you prefer deactivating it only for the current comparison. You can also ask EMF Compare to remember your choice by checking the checkbox in the bottom left corner.
<img border="0" src="../images/EMF_Compare_Tuto_New_Library_Comparison_Cascading_Filter_Popup.png"/>
</li>
</ul>
<p>
<b> Blocked by
<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=435051">https://bugs.eclipse.org/bugs/show_bug.cgi?id=435051</a>
</b>
<img border="0" src="../images/EMF_Compare_Tuto_Scenario3_Pseudo_Conflict_Filter.png"/>
</p>
<p>EMF Compare has detected two differences. The first difference has been detected between the common ancestor and Scenario2. The second has been detected between the common ancestor and Scenario3. However EMF Compare is clever enough to consider that these two differences are the same. </p>
<h5 id="Scenario_4_and_5:_Advanced_conflict">Scenario 4 and 5: Advanced conflict</h5>
<p>Now that you have understood how conflicts works we are going to create a more complex conflict. Let's create a conflict between a book that we are going to delete in a scenario (Scenario4) and the same book that we are going to borrow in another scenario (Scenario5). </p>
<ul>
<li>Create a new scenario named "Scenario4" from the master branch (see
<a href="#Create_Scenario_1">Create Scenario 1</a> to see how to create a new scenario).
</li>
<li>Delete the book "Prelude to Foundation".</li>
<li>Save.
<dl>
<dd>
<img border="0" src="../images/EMF_Compare_Tuto_Scenario4_Setting.png"/>
</dd>
</dl>
</li>
<li>Commit with the message "Deletion of prelude to foundation" (see
<a href="#Commit_your_changes">Commit your changes</a>).
<dl>
<dd>
<img border="0" src="../images/EMF_Compare_Tuto_Scenario4_Commit.png"/>
</dd>
</dl>
</li>
<li>Create a new scenario "Scenario5" from master (see
<a href="#Create_Scenario_1">Create Scenario 1</a> to see how to create a new scenario).
<dl>
<dd>
<img border="0" src="../images/EMF_Compare_Tuto_Scenario5_Branches.png"/>
</dd>
</dl>
</li>
</ul>
<p>At this stage of the tutorial your Git repository should look like this.</p>
<ul>
<li>Make "Will Graham" borrows "Prelude to foundation".</li>
<li>Save.
<dl>
<dd>
<img border="0" src="../images/EMF_Compare_Tuto_Scenario5_Setting.png"/>
</dd>
</dl>
</li>
<li>Commit with the message "Will Graham borrows a book" (see
<a href="#Commit_your_changes">Commit your changes</a>).
</li>
<li>Compare scenario 5 with scenario 4 (see
<a href="#Scenario_3:_Pseudo_conflict">Compare with branch</a> for further information).
<dl>
<dd>
<img border="0" src="../images/EMF_Compare_Tuto_Scenario5_Comparison.png"/>
</dd>
</dl>
</li>
</ul>
<p>If you select each differences you will see that:</p>
<ul>
<li>"Book Prelude to foundation[stock delete]" cannot be merged with the two other differences.
<dl>
<dd>
<img border="0" src="../images/EMF_Compare_Tuto_Scenario5_Diff_Dependencies.png"/>
</dd>
</dl>
<ul>
<li>Accept the difference to get:
<dl>
<dd>
<img border="0" src="../images/EMF_Compare_Tuto_Scenario5_Deletion_Accepted.png"/>
</dd>
</dl>
</li>
<li>Reject the difference to get:
<dl>
<dd>
<img border="0" src="../images/EMF_Compare_Tuto_Scenario5_Deletion_Rejected.png"/>
</dd>
<dd>Rejecting it does not automatically accept the other differences. Indeed you can prevent the deletion of the book but still want to choose to accept or reject the other difference.</dd>
</dl>
</li>
</ul>
</li>
<li>"Borrower Graham[borrowers add]" and "Book Prelude to foundation[borrowed add]" are equivalent and they cannot be merged with the third difference.
<dl>
<dd>
<img border="0" src="../images/EMF_Compare_Tuto_Scenario5_Diff_Dependencies2.png"/>
</dd>
</dl>
<ul>
<li>Accept one of them to get:
<dl>
<dd>
<img border="0" src="../images/EMF_Compare_Tuto_Scenario5_Set_Ref_Accepted.png"/>
</dd>
</dl>
</li>
<li>Reject one of them to get:
<dl>
<dd>
<img border="0" src="../images/EMF_Compare_Tuto_Scenario5_Set_Ref_Rejected.png"/>
</dd>
<dd>The same conclusion goes here. You can reject the setting of the reference and still want to choose what to do with the "delete" difference.</dd>
</dl>
</li>
</ul>
</li>
</ul>
<h5 id="Fragment_your_model">Fragment your model</h5>
<p>Let's say you want to delegate the work on the sub library to one of your colleagues. To do so you want to give him a file with the sub library and nothing else. Let's extract our new branch library into a new file. In this part of the tutorial we are going to discuss the fragmentation of a model (also called control). The following steps will show you how EMF Compare reacts with models split among several files. </p>
<ul>
<li>Create "Scenario6" from the master branch (see
<a href="#Create_Scenario_1">Create Scenario 1</a> to see how to create a new scenario).
</li>
<li>Open the model editor.</li>
<li>Control the branch library:
<ul>
<li>Select the sub library.</li>
<li>Open the contextual menu: "Control...".
<dl>
<dd>
<img border="0" src="../images/EMF_Compare_Tuto_Control_Library.png"/>
</dd>
</dl>
</li>
<li>Set the path of the new target file (Use "Browse Workspace..." button for convenience).
<dl>
<dd>
<img border="0" src="../images/EMF_Compare_Tuto_Control_Library_Set_URI.png"/>
</dd>
</dl>
</li>
</ul>
</li>
<li>Save (A new file appears in your project).</li>
<li>Close the model editor.</li>
<li>Open the model editor (it needs to be reloaded to see the control decorator).</li>
</ul>
<p>
<img border="0" src="../images/EMF_Compare_Tuto_Controled_Model.png"/>
In your new model you can see that two resources have been loaded (NewLibraryFile.extlibrary and TutorialModel.extlibrary). You can also notice a new overlay icon on the sub library. This means this element is stored in another file (resource).
</p>
<ul>
<li>Compare with HEAD (see
<a href="#Change_the_number_of_pages">Compare with HEAD</a>).
</li>
</ul>
<p>Eclipse asks you to switch to the "Team Synchronize" perspective, accept.</p>
<p>
<b>Blocked
<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=435081">https://bugs.eclipse.org/bugs/show_bug.cgi?id=435081</a>
</b>
</p>
<p>
<i>TODO when included in repository - Rebase two branches - Rebase your work on the work of your colleague</i>
<i>TODO when included in repository - Merge two branches - Merge your work with that of your colleague</i>
</p>
<p>Part of
<a href="../index.html">EMF Compare Documentation</a>
</p>
<p>Version 3.1.0.201506080946</p>
</body>
</html>