Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "EMF Compare/Specifications/MergeExtension"

Line 5: Line 5:
 
== Preamble  ==
 
== Preamble  ==
  
Often, when comparing textual attribute, neither the local nor the remote value is the one the user wants to
+
It enables to provide his own merger implementation for a set of differences concerned by a given predicate.
keep. We will relax the read-only constraint on textual compare viewer. As soon as the left or the right side is
+
edited, the associated difference will be marked as rejected.
+
  
 
*[https://bugs.eclipse.org/bugs/show_bug.cgi?id=398863 Bug 398863] - Provide a merge extension mechanism
 
*[https://bugs.eclipse.org/bugs/show_bug.cgi?id=398863 Bug 398863] - Provide a merge extension mechanism
 +
 +
 +
== Introduction ==
 +
 +
The merge operation is implemented on a per difference type. It has three implementations in the core engine (ReferenceChange, AttributeChange and ResourceAttachmentChange). Each extension (UML, GMF Notation) has to provide its own type of difference to override the merge semantic. This is not very flexible and the required number of difference types it requires to implement does not add any value.
 +
  
 
== Detailed Specification  ==
 
== Detailed Specification  ==
Line 20: Line 24:
  
 
Standard merge operations will be rewritten with the lowest ranking in order to be overrideable.
 
Standard merge operations will be rewritten with the lowest ranking in order to be overrideable.
 +
 +
 +
== Backward Compatibility and Migration Paths ==
 +
 +
=== Metamodel Changes ===
 +
 +
This evolution does not change any metamodel.
 +
 +
=== API Changes ===
 +
 +
* Add interfaces:
 +
<source lang="java">
 +
public interface IMerger {
 +
 +
boolean isMergerFor(Diff target);
 +
 +
int getRanking();
 +
 +
void setRanking(int parseInt);
 +
 +
void copyRightToLeft(Diff target, Monitor monitor);
 +
 +
void copyLeftToRight(Diff target, Monitor monitor);
 +
 +
void setRegistry(Registry registry);
 +
 +
Registry getRegistry();
 +
 +
interface Registry {
 +
 +
IMerger getHighestRankingMerger(Diff target);
 +
 +
Collection<IMerger> getMergers(Diff target);
 +
 +
IMerger add(IMerger merger);
 +
 +
IMerger remove(String className);
 +
 +
void clear();
 +
}
 +
 +
}
 +
</source>
 +
 +
* Add extension point:
 +
<source lang="xml">
 +
<extension-point id="mergerExtension" name="Merger Extension" schema="schema/MergerExtension.exsd"/>
 +
</source>
 +
Example of use:
 +
<source lang="xml">
 +
<extension
 +
    point="org.eclipse.emf.compare.mergerExtension">
 +
  <merger
 +
        class="org.eclipse.emf.compare.extension.merge.DefaultMerger"
 +
        ranking="0">
 +
  </merger>
 +
</extension>
 +
</source>
 +
 +
* Change of createCopyCommand() and createCopyAllNonConflictingCommand() methods in ICompareEditingDomain:
 +
<source lang="java">
 +
Command createCopyCommand(Diff diff, boolean leftToRight, IMerger.Registry mergerRegistry);
 +
Command createCopyAllNonConflictingCommand(List<? extends Diff> differences, boolean leftToRight, IMerger.Registry mergerRegistry);
 +
</source>
 +
 +
=== User Interface Changes ===
 +
 +
This evolution does not change any user interface.
 +
 +
=== Documentation Changes ===
 +
 +
This documentation will have to be updated:
 +
*New and Noteworthy
 +
*Developer Guide
 +
 +
 +
== Tests and Non-regression strategy ==
 +
 +
JUnit tests: ExtensionMergeTest.java in o.e.e.c.tests, o.e.e.c.diagram.ecoretools.tests, o.e.e.c.uml2.tests.
 +
 +
Manual tests: Detection of the extension launching a merge action.
 +
 +
 +
== Implementation choices and tradeoffs  ==
 +
 +
N/A

Revision as of 10:20, 28 January 2013

Evolution Specification: Provide a merge extension mechanism

Current status is DRAFT

Preamble

It enables to provide his own merger implementation for a set of differences concerned by a given predicate.


Introduction

The merge operation is implemented on a per difference type. It has three implementations in the core engine (ReferenceChange, AttributeChange and ResourceAttachmentChange). Each extension (UML, GMF Notation) has to provide its own type of difference to override the merge semantic. This is not very flexible and the required number of difference types it requires to implement does not add any value.


Detailed Specification

We propose to provide a merge extension mechanism.

Any extension will be able to contribute a merger on a subclass of Diff. The mergers registry will be queried each time a merge about to be performed. A merger contribution will provide its own predicate that will need to be verified before it is considered to be a valid candidate for a difference. It will also have a ranking in order to choose over multiple possible merger for a given difference.

Standard merge operations will be rewritten with the lowest ranking in order to be overrideable.


Backward Compatibility and Migration Paths

Metamodel Changes

This evolution does not change any metamodel.

API Changes

  • Add interfaces:
public interface IMerger {
 
	boolean isMergerFor(Diff target);
 
	int getRanking();
 
	void setRanking(int parseInt);
 
	void copyRightToLeft(Diff target, Monitor monitor);
 
	void copyLeftToRight(Diff target, Monitor monitor);
 
	void setRegistry(Registry registry);
 
	Registry getRegistry();
 
	interface Registry {
 
		IMerger getHighestRankingMerger(Diff target);
 
		Collection<IMerger> getMergers(Diff target);
 
		IMerger add(IMerger merger);
 
		IMerger remove(String className);
 
		void clear();
	}
 
}
  • Add extension point:
<extension-point id="mergerExtension" name="Merger Extension" schema="schema/MergerExtension.exsd"/>

Example of use:

<extension
    point="org.eclipse.emf.compare.mergerExtension">
   <merger
         class="org.eclipse.emf.compare.extension.merge.DefaultMerger"
         ranking="0">
   </merger>
</extension>
  • Change of createCopyCommand() and createCopyAllNonConflictingCommand() methods in ICompareEditingDomain:
Command createCopyCommand(Diff diff, boolean leftToRight, IMerger.Registry mergerRegistry);	
Command createCopyAllNonConflictingCommand(List<? extends Diff> differences, boolean leftToRight, IMerger.Registry mergerRegistry);

User Interface Changes

This evolution does not change any user interface.

Documentation Changes

This documentation will have to be updated:

  • New and Noteworthy
  • Developer Guide


Tests and Non-regression strategy

JUnit tests: ExtensionMergeTest.java in o.e.e.c.tests, o.e.e.c.diagram.ecoretools.tests, o.e.e.c.uml2.tests.

Manual tests: Detection of the extension launching a merge action.


Implementation choices and tradeoffs

N/A

Back to the top