Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-12-18 10:18:52 +0000
committerEike Stepper2012-12-18 10:18:52 +0000
commit5794c870bd7746b6bd35014804599c0f6da961ec (patch)
tree999f5bb63979b08e68f875e65c3d4281a2c2af44 /plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo
parent0739f1f0d2655e39849c3e52d9bdc2b93fd3493d (diff)
downloadcdo-5794c870bd7746b6bd35014804599c0f6da961ec.tar.gz
cdo-5794c870bd7746b6bd35014804599c0f6da961ec.tar.xz
cdo-5794c870bd7746b6bd35014804599c0f6da961ec.zip
[396818] Add EMF Compare merge support
https://bugs.eclipse.org/bugs/show_bug.cgi?id=396818
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo')
-rw-r--r--plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/CDOCompareUtil.java607
-rw-r--r--plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/CDOComparison.java64
-rw-r--r--plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/CDOComparisonScope.java11
-rw-r--r--plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/CloseableComparison.java23
-rw-r--r--plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/ComparisonScopeAdapter.java38
-rw-r--r--plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/DelegatingComparison.java196
6 files changed, 111 insertions, 828 deletions
diff --git a/plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/CDOCompareUtil.java b/plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/CDOCompareUtil.java
index 05d3778225..a8b927d303 100644
--- a/plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/CDOCompareUtil.java
+++ b/plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/CDOCompareUtil.java
@@ -14,17 +14,14 @@ import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.compare.CDOComparisonScope.AllContents;
import org.eclipse.emf.cdo.compare.CDOComparisonScope.Minimal;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.eresource.CDOResourceFolder;
import org.eclipse.emf.cdo.eresource.CDOResourceNode;
-import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.emf.common.notify.Notifier;
@@ -58,28 +55,21 @@ import java.util.Set;
* and returns {@link Match matches} for <b>all</b> elements of its {@link EObject#eAllContents() content tree}. This scope has the advantage that the comparison can
* be rooted at specific objects that are different from (below of) the root resource. The disadvantage is that all the transitive children of this specific object are
* matched, whether they differ or not. Major parts of huge repositories can be loaded to the client side easily, if no attention is paid.
- * The following methods return comparisons that are based on this scope algorithm:
+ * The following method returns comparisons that are based on this scope algorithm:
* <ul>
- * <li>{@link #compare(EObject, CDOBranchPoint)}
- * <li>{@link #compare(EObject, CDOBranchPoint, boolean)}
+ * <li>{@link #compare(CDOObject, CDOView, CDOView[])}
* </ul>
* <li>{@link Minimal CDOComparisonScope.Minimal} takes a {@link CDOView view}/{@link CDOTransaction transaction}
* and returns {@link Match matches} only for the <b>changed</b> elements of the entire content tree of its {@link CDOView#getRootResource() root resource}.
* The advantage of this scope is that CDO-specific mechanisms are used to efficiently (remotely) determine the set of changed objects. Only those and their container
* objects are considered as matches, making this scope scale seamlessly with the overall size of a repository.
- * The following methods return comparisons that are based on this scope algorithm:
+ * The following method returns comparisons that are based on this scope algorithm:
* <ul>
- * <li>{@link #compare(CDOView, CDOBranchPoint)}
- * <li>{@link #compare(CDOView, CDOBranchPoint, boolean)}
+ * <li>{@link #compare(CDOView, CDOView, CDOView[])}
* </ul>
* </ul>
- * The {@link IComparisonScope#getRight() right side} of a comparison is specified as a {@link CDOBranchPoint} which, among others, can be another {@link CDOView}
- * (which then is not closed when the comparison is closed) or a {@link CDOCommitInfo}. The {@link IComparisonScope#getOrigin() origin side} of a comparison is
- * automatically {@link CDOBranchUtil#getAncestor(CDOBranchPoint, CDOBranchPoint) determined} by inspecting the {@link CDOBranch branch tree} and used if its different from the left or right side.
- * <p>
- * The comparions returned from these factory methods are all of the type {@link CloseableComparison} and the caller is responsible to call {@link CloseableComparison#close()}
- * on them when they're not needed anymore. The reason is that the scopes may or may not open a number of addional {@link CDOView views} on the local {@link CDOSession session}
- * that need to be closed at some point.
+ * The {@link IComparisonScope#getOrigin() origin side} of a comparison is automatically {@link CDOBranchUtil#getAncestor(CDOBranchPoint, CDOBranchPoint) determined} by
+ * inspecting the {@link CDOBranch branch tree} and used if its different from the left or right side.
* <p>
* The {@link IEObjectMatcher matcher} used by the comparisons is based on an {@link CDOIDFunction ID function} that considers the {@link CDOID}s of the {@link CDOObject objects}.
* {@link CDOResource Resources} and {@link CDOResourceFolder folders} are treated as normal {@link EObject}s.
@@ -88,93 +78,30 @@ import java.util.Set;
*/
public final class CDOCompareUtil
{
- /**
- * @author Eike Stepper
- */
- private static final class CDOMatchEngine extends DefaultMatchEngine
- {
- private CDOMatchEngine(IEObjectMatcher matcher, IComparisonFactory comparisonFactory)
- {
- super(matcher, comparisonFactory);
- }
-
- /**
- * FIXME: CDO-specific.
- */
- @Override
- protected void match(Comparison comparison, IComparisonScope scope, final Notifier left, final Notifier right,
- final Notifier origin, Monitor monitor)
- {
- match(comparison, scope, (EObject)left, (EObject)right, (EObject)origin, monitor);
- }
- }
-
private CDOCompareUtil()
{
}
/**
- * Same as {@link #compare(CDOView, CDOBranchPoint, boolean) compare(leftRoot, right, true)}.
- */
- public static CDOComparison compare(EObject leftRoot, CDOBranchPoint right)
- {
- return compare(leftRoot, right, true);
- }
-
- /**
* Takes an arbitrary {@link CDOObject object} (including {@link CDOResourceNode resource nodes}) and returns {@link Match matches} for <b>all</b> elements of its {@link EObject#eAllContents() content tree}. This scope has the advantage that the comparison can
* be rooted at specific objects that are different from (below of) the root resource. The disadvantage is that all the transitive children of this specific object are
* matched, whether they differ or not. Major parts of huge repositories can be loaded to the client side easily, if no attention is paid.
*/
- public static CDOComparison compare(EObject leftRoot, CDOBranchPoint right, boolean tryThreeWay)
+ public static Comparison compare(CDOObject left, CDOView rightView, CDOView[] originView)
{
- Set<Object> objectsToDeactivateOnClose = new HashSet<Object>();
-
- CDOObject leftObject = CDOUtil.getCDOObject(leftRoot);
- CDOView leftView = leftObject.cdoView();
- CDOBranchPoint left = CDOBranchUtil.copyBranchPoint(leftView);
- CDOSession session = leftView.getSession();
-
- CDOView rightView;
- if (right instanceof CDOView)
+ CDOView leftView = left.cdoView();
+ if (leftView.getSession() != rightView.getSession())
{
- rightView = (CDOView)right;
- if (rightView.getSession() != session)
- {
- throw new IllegalArgumentException("Sessions are different");
- }
- }
- else
- {
- rightView = session.openView(right);
- objectsToDeactivateOnClose.add(rightView);
+ throw new IllegalArgumentException("Sessions are different");
}
- Notifier rightObject = rightView.getObject(leftObject);
-
- CDOView originView = null;
- Notifier originObject = null;
- if (tryThreeWay)
- {
- CDOBranchPoint ancestor = CDOBranchUtil.getAncestor(left, right);
- if (!ancestor.equals(left) && !ancestor.equals(right))
- {
- originView = session.openView(ancestor);
- originObject = originView.getObject(leftObject);
- objectsToDeactivateOnClose.add(originView);
- }
- }
+ CDOView view = openOriginView(leftView, rightView, originView);
- IComparisonScope scope = new CDOComparisonScope.AllContents(leftObject, rightObject, originObject);
- return createComparison(scope, objectsToDeactivateOnClose);
- }
+ CDOObject right = rightView.getObject(left);
+ CDOObject origin = view == null ? null : view.getObject(left);
- /**
- * Same as {@link #compare(EObject, CDOBranchPoint, boolean) compare(leftView, right, true)}.
- */
- public static CDOComparison compare(CDOView leftView, CDOBranchPoint right)
- {
- return compare(leftView, right, true);
+ IComparisonScope scope = new CDOComparisonScope.AllContents(left, right, origin);
+ return createComparison(scope);
}
/**
@@ -183,54 +110,58 @@ public final class CDOCompareUtil
* The advantage of this scope is that CDO-specific mechanisms are used to efficiently (remotely) determine the set of changed objects. Only those and their container
* objects are considered as matches, making this scope scale seamlessly with the overall size of a repository.
*/
- public static CDOComparison compare(CDOView leftView, CDOBranchPoint right, boolean tryThreeWay)
+ public static Comparison compare(CDOView leftView, CDOView rightView, CDOView[] originView)
{
- Set<Object> objectsToDeactivateOnClose = new HashSet<Object>();
- CDOSession session = leftView.getSession();
+ InternalCDOSession session = (InternalCDOSession)leftView.getSession();
+ if (rightView.getSession() != session)
+ {
+ throw new IllegalArgumentException("Sessions are different");
+ }
- CDOView rightView;
- if (right instanceof CDOView)
+ CDOView view = openOriginView(leftView, rightView, originView);
+
+ Set<CDOID> ids;
+ if (view != null)
{
- rightView = (CDOView)right;
- if (rightView.getSession() != session)
- {
- throw new IllegalArgumentException("Sessions are different");
- }
+ MergeData mergeData = session.getMergeData(leftView, rightView, view, false);
+ ids = mergeData.getIDs();
}
else
{
- rightView = session.openView(right);
- objectsToDeactivateOnClose.add(rightView);
+ CDOChangeSetData changeSetData = leftView.compareRevisions(rightView);
+ ids = new HashSet<CDOID>(changeSetData.getChangeKinds().keySet());
}
- CDOView originView = null;
- if (tryThreeWay)
+ IComparisonScope scope = new CDOComparisonScope.Minimal(leftView, rightView, view, ids);
+ return createComparison(scope);
+ }
+
+ private static CDOView openOriginView(CDOView leftView, CDOView rightView, CDOView[] originView)
+ {
+ if (originView != null)
{
+ if (originView.length != 1)
+ {
+ throw new IllegalArgumentException("originView.length != 1");
+ }
+
+ if (originView[0] != null)
+ {
+ throw new IllegalArgumentException("originView[0] != null");
+ }
+
CDOBranchPoint ancestor = CDOBranchUtil.getAncestor(leftView, rightView);
if (!ancestor.equals(leftView) && !ancestor.equals(rightView))
{
- originView = session.openView(ancestor);
- objectsToDeactivateOnClose.add(originView);
+ originView[0] = leftView.getSession().openView(ancestor);
+ return originView[0];
}
}
- Set<CDOID> ids;
- if (originView != null)
- {
- MergeData mergeData = ((InternalCDOSession)session).getMergeData(leftView, rightView, null, false);
- ids = mergeData.getIDs();
- }
- else
- {
- CDOChangeSetData changeSetData = leftView.compareRevisions(right);
- ids = new HashSet<CDOID>(changeSetData.getChangeKinds().keySet());
- }
-
- IComparisonScope scope = new CDOComparisonScope.Minimal(leftView, rightView, originView, ids);
- return createComparison(scope, objectsToDeactivateOnClose);
+ return null;
}
- private static EMFCompare createComparator()
+ private static Comparison createComparison(IComparisonScope scope)
{
Function<EObject, String> idFunction = new CDOIDFunction();
IEObjectMatcher matcher = new IdentifierEObjectMatcher(idFunction);
@@ -238,427 +169,27 @@ public final class CDOCompareUtil
IComparisonFactory comparisonFactory = new DefaultComparisonFactory(new DefaultEqualityHelperFactory());
IMatchEngine matchEngine = new CDOMatchEngine(matcher, comparisonFactory);
EMFCompare comparator = EMFCompare.builder().setMatchEngine(matchEngine).build();
- return comparator;
- }
- private static CDOComparison createComparison(IComparisonScope scope, Set<Object> objectsToDeactivateOnClose)
- {
- EMFCompare comparator = createComparator();
Comparison comparison = comparator.compare(scope);
- return new CDOComparison(scope, comparison, objectsToDeactivateOnClose);
+ comparison.eAdapters().add(new ComparisonScopeAdapter(scope));
+ return comparison;
}
- // /**
- // * FIXME: To be removed when bug 390849 is resolved.
- // *
- // * @author Eike Stepper
- // */
- // private static final class _EMFCompare
- // {
- // private IEObjectMatcher eObjectMatcher;
- //
- // private Monitor progressMonitor;
- //
- // private final IComparisonScope scope;
- //
- // private _EMFCompare(IComparisonScope scope)
- // {
- // com.google.common.base.Preconditions.checkNotNull(scope);
- // this.scope = scope;
- // }
- //
- // public static EMFCompare newComparator(IComparisonScope scope)
- // {
- // return null; // Just temporary fix to make the Kepler train run again!
- //
- // // return new EMFCompare(scope);
- // }
- //
- // private static Comparison compare(IComparisonScope scope, EMFCompareConfiguration configuration,
- // IEObjectMatcher matcher)
- // {
- // final IMatchEngine matchEngine = new DefaultMatchEngine(matcher)
- // {
- // /**
- // * FIXME: CDO-specific.
- // */
- // @Override
- // protected void match(Notifier left, Notifier right, Notifier origin)
- // {
- // match((EObject)left, (EObject)right, (EObject)origin);
- // }
- // };
- //
- // Comparison comparison = matchEngine.match(scope, configuration);
- //
- // IPostProcessor postProcessor = getPostProcessor(scope);
- // if (postProcessor != null)
- // {
- // postProcessor.postMatch(comparison);
- // }
- //
- // final IDiffProcessor diffBuilder = new DiffBuilder();
- //
- // final IDiffEngine diffEngine = new DefaultDiffEngine(diffBuilder);
- // diffEngine.diff(comparison);
- //
- // if (postProcessor != null)
- // {
- // postProcessor.postDiff(comparison);
- // }
- //
- // final IReqEngine reqEngine = new DefaultReqEngine();
- // reqEngine.computeRequirements(comparison);
- //
- // if (postProcessor != null)
- // {
- // postProcessor.postRequirements(comparison);
- // }
- //
- // final IEquiEngine equiEngine = new DefaultEquiEngine();
- // equiEngine.computeEquivalences(comparison);
- //
- // if (postProcessor != null)
- // {
- // postProcessor.postEquivalences(comparison);
- // }
- //
- // if (comparison.isThreeWay())
- // {
- // final IConflictDetector conflictDetector = new DefaultConflictDetector();
- // conflictDetector.detect(comparison);
- //
- // if (postProcessor != null)
- // {
- // postProcessor.postConflicts(comparison);
- // }
- // }
- //
- // return comparison;
- // }
- //
- // private static IPostProcessor getPostProcessor(IComparisonScope scope)
- // {
- // IPostProcessor postProcessor = null;
- // final Iterator<PostProcessorDescriptor> postProcessorIterator = EMFCompareExtensionRegistry
- // .getRegisteredPostProcessors().iterator();
- // while (postProcessorIterator.hasNext() && postProcessor == null)
- // {
- // final PostProcessorDescriptor descriptor = postProcessorIterator.next();
- // if (descriptor.getNsURI() != null && descriptor.getNsURI().trim().length() != 0)
- // {
- // final Iterator<String> nsUris = scope.getNsURIs().iterator();
- // while (nsUris.hasNext() && postProcessor == null)
- // {
- // if (nsUris.next().matches(descriptor.getNsURI()))
- // {
- // postProcessor = descriptor.getPostProcessor();
- // }
- // }
- // }
- //
- // if (descriptor.getResourceURI() != null && descriptor.getResourceURI().trim().length() != 0)
- // {
- // final Iterator<String> resourceUris = scope.getResourceURIs().iterator();
- // while (resourceUris.hasNext() && postProcessor == null)
- // {
- // if (resourceUris.next().matches(descriptor.getResourceURI()))
- // {
- // postProcessor = descriptor.getPostProcessor();
- // }
- // }
- // }
- // }
- // return postProcessor;
- // }
- //
- // public Comparison compare()
- // {
- // final Monitor monitor;
- // if (progressMonitor != null)
- // {
- // monitor = progressMonitor;
- // }
- // else
- // {
- // monitor = new BasicMonitor();
- // }
- //
- // EqualityHelper helper = new EqualityHelper();
- // EMFCompareConfiguration configuration = new EMFCompareConfiguration(monitor, helper);
- // IEObjectMatcher matcher = createMatcher(helper);
- //
- // return compare(scope, configuration, matcher);
- // }
- //
- // public EMFCompare setEObjectMatcher(IEObjectMatcher matcher)
- // {
- // if (matcher != null)
- // {
- // eObjectMatcher = matcher;
- // }
- // return this;
- // }
- //
- // private IEObjectMatcher createMatcher(EqualityHelper helper)
- // {
- // return eObjectMatcher;
- // }
- //
- // /**
- // * FIXME: Remove this when bug 390846 has been resolved.
- // *
- // * @author Eike Stepper
- // */
- // private static class DefaultMatchEngine implements IMatchEngine
- // {
- // private Comparison comparison;
- //
- // private IComparisonScope comparisonScope;
- //
- // private IEObjectMatcher eObjectMatcher;
- //
- // public DefaultMatchEngine(IEObjectMatcher matcher)
- // {
- // com.google.common.base.Preconditions.checkNotNull(matcher);
- // eObjectMatcher = matcher;
- // }
- //
- // public Comparison match(IComparisonScope scope, EMFCompareConfiguration configuration)
- // {
- // comparisonScope = scope;
- // associate(getComparison(), configuration);
- //
- // final Notifier left = getScope().getLeft();
- // final Notifier right = getScope().getRight();
- // final Notifier origin = getScope().getOrigin();
- //
- // getComparison().setThreeWay(origin != null);
- //
- // match(left, right, origin);
- //
- // return getComparison();
- // }
- //
- // protected void match(final Notifier left, final Notifier right, final Notifier origin)
- // {
- // if (left instanceof ResourceSet || right instanceof ResourceSet)
- // {
- // match((ResourceSet)left, (ResourceSet)right, (ResourceSet)origin);
- // }
- // else if (left instanceof Resource || right instanceof Resource)
- // {
- // match((Resource)left, (Resource)right, (Resource)origin);
- // }
- // else if (left instanceof EObject || right instanceof EObject)
- // {
- // match((EObject)left, (EObject)right, (EObject)origin);
- // }
- // }
- //
- // protected void match(ResourceSet left, ResourceSet right, ResourceSet origin)
- // {
- // final Iterator<? extends Resource> leftChildren = getScope().getCoveredResources(left);
- // final Iterator<? extends Resource> rightChildren = getScope().getCoveredResources(right);
- // final Iterator<? extends Resource> originChildren;
- // if (origin != null)
- // {
- // originChildren = getScope().getCoveredResources(origin);
- // }
- // else
- // {
- // originChildren = Iterators.emptyIterator();
- // }
- //
- // final IResourceMatcher resourceMatcher = getResourceMatcher();
- // final Iterable<MatchResource> mappings = resourceMatcher.createMappings(leftChildren, rightChildren,
- // originChildren);
- //
- // Iterator<? extends EObject> leftEObjects = Iterators.emptyIterator();
- // Iterator<? extends EObject> rightEObjects = Iterators.emptyIterator();
- // Iterator<? extends EObject> originEObjects = Iterators.emptyIterator();
- //
- // for (MatchResource mapping : mappings)
- // {
- // getComparison().getMatchedResources().add(mapping);
- //
- // final Resource leftRes = mapping.getLeft();
- // final Resource rightRes = mapping.getRight();
- // final Resource originRes = mapping.getOrigin();
- //
- // if (leftRes != null)
- // {
- // leftEObjects = Iterators.concat(leftEObjects, getScope().getCoveredEObjects(leftRes));
- // }
- //
- // if (rightRes != null)
- // {
- // rightEObjects = Iterators.concat(rightEObjects, getScope().getCoveredEObjects(rightRes));
- // }
- //
- // if (originRes != null)
- // {
- // originEObjects = Iterators.concat(originEObjects, getScope().getCoveredEObjects(originRes));
- // }
- // }
- //
- // final Iterable<Match> matches = getEObjectMatcher().createMatches(leftEObjects, rightEObjects, originEObjects);
- // Iterables.addAll(getComparison().getMatches(), matches);
- // }
- //
- // protected void match(Resource left, Resource right, Resource origin)
- // {
- // // Our "roots" are Resources. Consider them matched
- // final MatchResource match = CompareFactory.eINSTANCE.createMatchResource();
- //
- // match.setLeft(left);
- // match.setRight(right);
- // match.setOrigin(origin);
- //
- // if (left != null)
- // {
- // URI uri = left.getURI();
- // if (uri != null)
- // {
- // match.setLeftURI(uri.toString());
- // }
- // }
- //
- // if (right != null)
- // {
- // URI uri = right.getURI();
- // if (uri != null)
- // {
- // match.setRightURI(uri.toString());
- // }
- // }
- //
- // if (origin != null)
- // {
- // URI uri = origin.getURI();
- // if (uri != null)
- // {
- // match.setOriginURI(uri.toString());
- // }
- // }
- //
- // getComparison().getMatchedResources().add(match);
- //
- // // We need at least two resources to match them
- // if (atLeastTwo(left == null, right == null, origin == null))
- // {
- // return;
- // }
- //
- // final Iterator<? extends EObject> leftEObjects;
- // if (left != null)
- // {
- // leftEObjects = getScope().getCoveredEObjects(left);
- // }
- // else
- // {
- // leftEObjects = Iterators.emptyIterator();
- // }
- // final Iterator<? extends EObject> rightEObjects;
- // if (right != null)
- // {
- // rightEObjects = getScope().getCoveredEObjects(right);
- // }
- // else
- // {
- // rightEObjects = Iterators.emptyIterator();
- // }
- // final Iterator<? extends EObject> originEObjects;
- // if (origin != null)
- // {
- // originEObjects = getScope().getCoveredEObjects(origin);
- // }
- // else
- // {
- // originEObjects = Iterators.emptyIterator();
- // }
- //
- // final Iterable<Match> matches = getEObjectMatcher().createMatches(leftEObjects, rightEObjects, originEObjects);
- //
- // Iterables.addAll(getComparison().getMatches(), matches);
- // }
- //
- // protected void match(EObject left, EObject right, EObject origin)
- // {
- // if (left == null || right == null)
- // {
- // throw new IllegalArgumentException();
- // }
- //
- // final Iterator<? extends EObject> leftEObjects = Iterators.concat(Iterators.singletonIterator(left), getScope()
- // .getChildren(left));
- // final Iterator<? extends EObject> rightEObjects = Iterators.concat(Iterators.singletonIterator(right),
- // getScope().getChildren(right));
- // final Iterator<? extends EObject> originEObjects;
- // if (origin != null)
- // {
- // originEObjects = Iterators.concat(Iterators.singletonIterator(origin), getScope().getChildren(origin));
- // }
- // else
- // {
- // originEObjects = Iterators.emptyIterator();
- // }
- //
- // final Iterable<Match> matches = getEObjectMatcher().createMatches(leftEObjects, rightEObjects, originEObjects);
- //
- // Iterables.addAll(getComparison().getMatches(), matches);
- // }
- //
- // protected IResourceMatcher getResourceMatcher()
- // {
- // return new StrategyResourceMatcher();
- // }
- //
- // protected IEObjectMatcher getEObjectMatcher()
- // {
- // return eObjectMatcher;
- // }
- //
- // protected Comparison getComparison()
- // {
- // if (comparison == null)
- // {
- // comparison = CompareFactory.eINSTANCE.createComparison();
- // }
- // return comparison;
- // }
- //
- // protected IComparisonScope getScope()
- // {
- // return comparisonScope;
- // }
- //
- // protected static boolean atLeastTwo(boolean condition1, boolean condition2, boolean condition3)
- // {
- // // CHECKSTYLE:OFF This expression is alone in its method, and documented.
- // return condition1 && (condition2 || condition3) || condition2 && condition3;
- // // CHECKSTYLE:ON
- // }
- //
- // private static void associate(Comparison comparison, EMFCompareConfiguration configuration)
- // {
- // Iterator<Adapter> eAdapters = comparison.eAdapters().iterator();
- // while (eAdapters.hasNext())
- // {
- // Adapter eAdapter = eAdapters.next();
- // if (eAdapter.isAdapterForType(EMFCompareConfiguration.class))
- // {
- // eAdapters.remove();
- // if (eAdapter instanceof Adapter.Internal)
- // {
- // ((Adapter.Internal)eAdapter).unsetTarget(comparison);
- // }
- // }
- // }
- //
- // comparison.eAdapters().add(configuration);
- // configuration.setTarget(comparison);
- // }
- // }
- // }
+ /**
+ * @author Eike Stepper
+ */
+ private static final class CDOMatchEngine extends DefaultMatchEngine
+ {
+ private CDOMatchEngine(IEObjectMatcher matcher, IComparisonFactory comparisonFactory)
+ {
+ super(matcher, comparisonFactory);
+ }
+
+ @Override
+ protected void match(Comparison comparison, IComparisonScope scope, final Notifier left, final Notifier right,
+ final Notifier origin, Monitor monitor)
+ {
+ match(comparison, scope, (EObject)left, (EObject)right, (EObject)origin, monitor);
+ }
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/CDOComparison.java b/plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/CDOComparison.java
deleted file mode 100644
index d7c72c57fa..0000000000
--- a/plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/CDOComparison.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.compare;
-
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-
-import org.eclipse.emf.compare.Comparison;
-import org.eclipse.emf.compare.scope.IComparisonScope;
-
-import java.util.Set;
-
-/**
- * A {@link Comparison comparison} that can be closed to dispose of used resources.
- *
- * @author Eike Stepper
- */
-public class CDOComparison extends DelegatingComparison implements CloseableComparison
-{
- private final IComparisonScope scope;
-
- private Set<Object> objectsToDeactivateOnClose;
-
- public CDOComparison(IComparisonScope scope, Comparison delegate, Set<Object> objectsToDeactivateOnClose)
- {
- super(delegate);
- this.scope = scope;
- this.objectsToDeactivateOnClose = objectsToDeactivateOnClose;
- }
-
- public final IComparisonScope getScope()
- {
- return scope;
- }
-
- public boolean isClosed()
- {
- return delegate == null;
- }
-
- public void close()
- {
- if (delegate != null)
- {
- delegate = null;
- if (objectsToDeactivateOnClose != null)
- {
- for (Object object : objectsToDeactivateOnClose)
- {
- LifecycleUtil.deactivate(object);
- }
-
- objectsToDeactivateOnClose = null;
- }
- }
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/CDOComparisonScope.java b/plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/CDOComparisonScope.java
index 5e402f4bf9..585f398193 100644
--- a/plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/CDOComparisonScope.java
+++ b/plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/CDOComparisonScope.java
@@ -11,7 +11,6 @@
package org.eclipse.emf.cdo.compare;
import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.revision.CDORevision;
@@ -65,10 +64,9 @@ public abstract class CDOComparisonScope extends AbstractComparisonScope
* and returns {@link Match matches} for <b>all</b> elements of its {@link EObject#eAllContents() content tree}. This scope has the advantage that the comparison can
* be rooted at specific objects that are different from (below of) the root resource. The disadvantage is that all the transitive children of this specific object are
* matched, whether they differ or not. Major parts of huge repositories can be loaded to the client side easily, if no attention is paid.
- * The following methods return comparisons that are based on this scope algorithm:
+ * The following method returns comparisons that are based on this scope algorithm:
* <ul>
- * <li>{@link CDOCompareUtil#compare(EObject, CDOBranchPoint)}
- * <li>{@link CDOCompareUtil#compare(EObject, CDOBranchPoint, boolean)}
+ * <li>{@link CDOCompareUtil#compare(CDOObject, CDOView, CDOView[])}
* </ul>
*
* @author Eike Stepper
@@ -91,10 +89,9 @@ public abstract class CDOComparisonScope extends AbstractComparisonScope
* and returns {@link Match matches} only for the <b>changed</b> elements of the entire content tree of its {@link CDOView#getRootResource() root resource}.
* The advantage of this scope is that CDO-specific mechanisms are used to efficiently (remotely) determine the set of changed objects. Only those and their container
* objects are considered as matches, making this scope scale seamlessly with the overall size of a repository.
- * The following methods return comparisons that are based on this scope algorithm:
+ * The following method returns comparisons that are based on this scope algorithm:
* <ul>
- * <li>{@link CDOCompareUtil#compare(CDOView, CDOBranchPoint)}
- * <li>{@link CDOCompareUtil#compare(CDOView, CDOBranchPoint, boolean)}
+ * <li>{@link CDOCompareUtil#compare(CDOView, CDOView, CDOView[])}
* </ul>
*
* @author Eike Stepper
diff --git a/plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/CloseableComparison.java b/plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/CloseableComparison.java
deleted file mode 100644
index 8830d46f81..0000000000
--- a/plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/CloseableComparison.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.compare;
-
-import org.eclipse.net4j.util.collection.Closeable;
-
-import org.eclipse.emf.compare.Comparison;
-
-/**
- * A {@link Comparison comparison} that can be closed to dispose of used resources.
- * @author Eike Stepper
- */
-public interface CloseableComparison extends Comparison, Closeable
-{
-}
diff --git a/plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/ComparisonScopeAdapter.java b/plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/ComparisonScopeAdapter.java
new file mode 100644
index 0000000000..c8b1cdbf7f
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/ComparisonScopeAdapter.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.compare;
+
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.compare.scope.IComparisonScope;
+
+/**
+ * @author Eike Stepper
+ */
+public final class ComparisonScopeAdapter extends AdapterImpl
+{
+ private IComparisonScope scope;
+
+ public ComparisonScopeAdapter(IComparisonScope scope)
+ {
+ this.scope = scope;
+ }
+
+ public final IComparisonScope getScope()
+ {
+ return scope;
+ }
+
+ @Override
+ public boolean isAdapterForType(Object type)
+ {
+ return type == ComparisonScopeAdapter.class;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/DelegatingComparison.java b/plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/DelegatingComparison.java
deleted file mode 100644
index 47e8112bd9..0000000000
--- a/plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/DelegatingComparison.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.compare;
-
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.common.util.TreeIterator;
-import org.eclipse.emf.compare.Comparison;
-import org.eclipse.emf.compare.Conflict;
-import org.eclipse.emf.compare.Diff;
-import org.eclipse.emf.compare.Equivalence;
-import org.eclipse.emf.compare.Match;
-import org.eclipse.emf.compare.MatchResource;
-import org.eclipse.emf.compare.utils.IEqualityHelper;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EOperation;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.resource.Resource;
-
-import java.lang.reflect.InvocationTargetException;
-
-/**
- * A {@link Comparison comparison} that delegates all methods to another comparison.
- *
- * @author Eike Stepper
- */
-public class DelegatingComparison implements Comparison
-{
- protected Comparison delegate;
-
- public DelegatingComparison(Comparison delegate)
- {
- this.delegate = delegate;
- }
-
- public Comparison getDelegate()
- {
- return delegate;
- }
-
- public EList<Adapter> eAdapters()
- {
- return delegate.eAdapters();
- }
-
- public boolean eDeliver()
- {
- return delegate.eDeliver();
- }
-
- public void eSetDeliver(boolean deliver)
- {
- delegate.eSetDeliver(deliver);
- }
-
- public void eNotify(Notification notification)
- {
- delegate.eNotify(notification);
- }
-
- public EList<MatchResource> getMatchedResources()
- {
- return delegate.getMatchedResources();
- }
-
- public EList<Match> getMatches()
- {
- return delegate.getMatches();
- }
-
- public EClass eClass()
- {
- return delegate.eClass();
- }
-
- public EList<Conflict> getConflicts()
- {
- return delegate.getConflicts();
- }
-
- public Resource eResource()
- {
- return delegate.eResource();
- }
-
- public EList<Equivalence> getEquivalences()
- {
- return delegate.getEquivalences();
- }
-
- public EObject eContainer()
- {
- return delegate.eContainer();
- }
-
- public IEqualityHelper getEqualityHelper()
- {
- return delegate.getEqualityHelper();
- }
-
- public EList<Diff> getDifferences()
- {
- return delegate.getDifferences();
- }
-
- public EStructuralFeature eContainingFeature()
- {
- return delegate.eContainingFeature();
- }
-
- public EList<Diff> getDifferences(EObject element)
- {
- return delegate.getDifferences(element);
- }
-
- public Match getMatch(EObject element)
- {
- return delegate.getMatch(element);
- }
-
- public EReference eContainmentFeature()
- {
- return delegate.eContainmentFeature();
- }
-
- public boolean isThreeWay()
- {
- return delegate.isThreeWay();
- }
-
- public void setThreeWay(boolean value)
- {
- delegate.setThreeWay(value);
- }
-
- public EList<EObject> eContents()
- {
- return delegate.eContents();
- }
-
- public TreeIterator<EObject> eAllContents()
- {
- return delegate.eAllContents();
- }
-
- public boolean eIsProxy()
- {
- return delegate.eIsProxy();
- }
-
- public EList<EObject> eCrossReferences()
- {
- return delegate.eCrossReferences();
- }
-
- public Object eGet(EStructuralFeature feature)
- {
- return delegate.eGet(feature);
- }
-
- public Object eGet(EStructuralFeature feature, boolean resolve)
- {
- return delegate.eGet(feature, resolve);
- }
-
- public void eSet(EStructuralFeature feature, Object newValue)
- {
- delegate.eSet(feature, newValue);
- }
-
- public boolean eIsSet(EStructuralFeature feature)
- {
- return delegate.eIsSet(feature);
- }
-
- public void eUnset(EStructuralFeature feature)
- {
- delegate.eUnset(feature);
- }
-
- public Object eInvoke(EOperation operation, EList<?> arguments) throws InvocationTargetException
- {
- return delegate.eInvoke(operation, arguments);
- }
-}

Back to the top