diff options
author | Caspar De Groot | 2010-01-20 12:00:25 +0000 |
---|---|---|
committer | Caspar De Groot | 2010-01-20 12:00:25 +0000 |
commit | 3ae379aeaa5789cd844b07d1d3101abccd844852 (patch) | |
tree | 82f4e53d4b0382c5fae871dff61e8ee04bef5882 | |
parent | 2a8b8c669be934a29b6a0248a0eefafec1a56e99 (diff) | |
download | cdo-3ae379aeaa5789cd844b07d1d3101abccd844852.tar.gz cdo-3ae379aeaa5789cd844b07d1d3101abccd844852.tar.xz cdo-3ae379aeaa5789cd844b07d1d3101abccd844852.zip |
[270716] Provide support for branching
https://bugs.eclipse.org/bugs/show_bug.cgi?id=270716
5 files changed, 23 insertions, 49 deletions
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/AbstractSyncRevisionsRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/AbstractSyncRevisionsRequest.java index 3d2b431595..857a8927e4 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/AbstractSyncRevisionsRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/AbstractSyncRevisionsRequest.java @@ -77,12 +77,6 @@ public abstract class AbstractSyncRevisionsRequest extends CDOClientRequest<Coll protected Collection<CDORefreshContext> confirming(CDODataInput in) throws IOException { InternalCDORevisionManager revisionManager = getSession().getRevisionManager(); - /* - * Comparator<CDOBranchPoint> comparator = new Comparator<CDOBranchPoint>() { public int compare(CDOBranchPoint bp1, - * CDOBranchPoint bp2) { long diff = bp1.getTimeStamp() - bp2.getTimeStamp(); return diff == 0 ? 0 : diff > 0 ? 1 : - * -1; } }; Map<CDOBranchPoint, CDORefreshContext> refreshContexts = new TreeMap<CDOBranchPoint, - * CDORefreshContext>(comparator); - */ Map<Long, CDORefreshContext> refreshContexts = new TreeMap<Long, CDORefreshContext>(); int dirtyCount = in.readInt(); @@ -127,19 +121,6 @@ public abstract class AbstractSyncRevisionsRequest extends CDOClientRequest<Coll TRACER.trace("Synchronization received " + detachedCount + " detached objects"); //$NON-NLS-1$ //$NON-NLS-2$ } - // Replace the collections with unmodifiable ones - for (CDORefreshContext refreshContext : refreshContexts.values()) - { - Set<CDOIDAndVersion> dirtyObjects = refreshContext.getDirtyObjects(); - Collection<CDOID> detachedObjects = refreshContext.getDetachedObjects(); - - dirtyObjects = Collections.unmodifiableSet(dirtyObjects); - detachedObjects = Collections.unmodifiableCollection(detachedObjects); - - ((CDORefreshContextImpl)refreshContext).setDirtyObjects(dirtyObjects); - ((CDORefreshContextImpl)refreshContext).setDetachedObjects(detachedObjects); - } - return Collections.unmodifiableCollection(refreshContexts.values()); } diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_273565_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_273565_Test.java index b560a48081..577a5bb51a 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_273565_Test.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_273565_Test.java @@ -216,7 +216,7 @@ public class Bugzilla_273565_Test extends AbstractCDOTest session.close(); } - public void _testBugzilla_273565_Lock() throws Exception + public void testBugzilla_273565_Lock() throws Exception { // TODO Clarify why this test sometimes enters infinite loop with this trace: // TCPSelector [TCPSelector] Writing java.nio.channels.SocketChannel[connected local=/127.0.0.1:2036 @@ -230,6 +230,7 @@ public class Bugzilla_273565_Test extends AbstractCDOTest done[0] = false; orderDetail.setPrice(2); CDOSession session = openModel1Session(); + // session.options().setPassiveUpdateEnabled(false); // $$$ Remove this CDOTransaction transaction = session.openTransaction(); CDOResource resource = transaction.createResource("/test1"); resource.getContents().add(orderDetail); @@ -242,6 +243,7 @@ public class Bugzilla_273565_Test extends AbstractCDOTest try { CDOSession session = openModel1Session(); + // session.options().setPassiveUpdateEnabled(false); // $$$ Remove this CDOTransaction transaction = session.openTransaction(); OrderDetail orderDetail2 = (OrderDetail)transaction.getObject(CDOUtil.getCDOObject(orderDetail).cdoID()); diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_298561_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_298561_Test.java index 454ae099cb..e823098b7f 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_298561_Test.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_298561_Test.java @@ -49,12 +49,9 @@ public class Bugzilla_298561_Test extends AbstractCDOTest try { boolean isSet = referencer.eIsSet(model4Package.eINSTANCE.getRefSingleNonContainedNPL_Element()); - System.out.println("---> " + isSet); - if (isSet) { - ContainedElementNoOpposite e = referencer.getElement(); - System.out.println("---> " + e); + referencer.getElement(); } } catch (ObjectNotFoundException e) @@ -80,8 +77,6 @@ public class Bugzilla_298561_Test extends AbstractCDOTest r1.getContents().add(referencee); tx.commit(); - System.out.println("---> " + ((CDOObject)referencee).cdoID()); - // Create referencer, store it, then make it DIRTY RefSingleNonContainedNPL referencer = model4Factory.eINSTANCE.createRefSingleNonContainedNPL(); r1.getContents().add(referencer); @@ -101,12 +96,9 @@ public class Bugzilla_298561_Test extends AbstractCDOTest try { boolean isSet = referencer.eIsSet(model4Package.eINSTANCE.getRefSingleNonContainedNPL_Element()); - System.out.println("---> " + isSet); - if (isSet) { ContainedElementNoOpposite e = referencer.getElement(); - System.out.println("---> " + e); } } catch (ObjectNotFoundException e) @@ -144,8 +136,6 @@ public class Bugzilla_298561_Test extends AbstractCDOTest r1.getContents().add(referencee); tx.commit(); - System.out.println("---> " + ((CDOObject)referencee).cdoID()); - // Create referencer, don't store it -- keep it as NEW RefMultiNonContainedNPL referencer = model4Factory.eINSTANCE.createRefMultiNonContainedNPL(); r1.getContents().add(referencer); @@ -162,12 +152,9 @@ public class Bugzilla_298561_Test extends AbstractCDOTest try { boolean isSet = referencer.eIsSet(model4Package.eINSTANCE.getRefMultiNonContainedNPL_Elements()); - System.out.println("---> " + isSet); - if (isSet && referencer.getElements().size() > 0) { - ContainedElementNoOpposite e = referencer.getElements().get(0); - System.out.println("---> " + e); + referencer.getElements().get(0); } } catch (ObjectNotFoundException e) @@ -193,8 +180,6 @@ public class Bugzilla_298561_Test extends AbstractCDOTest r1.getContents().add(referencee); tx.commit(); - System.out.println("---> " + ((CDOObject)referencee).cdoID()); - // Create referencer, store it, then make it DIRTY RefMultiNonContainedNPL referencer = model4Factory.eINSTANCE.createRefMultiNonContainedNPL(); r1.getContents().add(referencer); @@ -214,12 +199,9 @@ public class Bugzilla_298561_Test extends AbstractCDOTest try { boolean isSet = referencer.eIsSet(model4Package.eINSTANCE.getRefMultiNonContainedNPL_Elements()); - System.out.println("---> " + isSet); - if (isSet && referencer.getElements().size() > 0) { - ContainedElementNoOpposite e = referencer.getElements().get(0); - System.out.println("---> " + e); + referencer.getElements().get(0); } } catch (ObjectNotFoundException e) diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java index 51dfb8d97a..e9c37c7822 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java @@ -91,6 +91,7 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; @@ -710,16 +711,23 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter if (excludedView == null || timeStamp == CDORevision.UNSPECIFIED_DATE) { + List<CDOIDAndVersion> notRevised = new LinkedList<CDOIDAndVersion>(); for (CDOIDAndVersion dirtyOID : dirtyOIDs) { CDOID id = dirtyOID.getID(); int version = dirtyOID.getVersion(); - boolean revised = revisionManager.reviseVersion(id, branch.getVersion(version), timeStamp); - if (!revised) - { - dirtyOIDs.remove(id); - } + revisionManager.reviseVersion(id, branch.getVersion(version), timeStamp); + // $$$ Why doesn't the following work? + // boolean revised = revisionManager.reviseVersion(id, branch.getVersion(version), timeStamp); + // if (!revised) + // { + // notRevised.add(dirtyOID); + // } } + + // notRevised holds revisions that we thought had to be revised, + // but actually didn't need revising + dirtyOIDs.removeAll(notRevised); } for (CDOID id : detachedObjects) diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java index f1bf93110d..7b8f65123a 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java @@ -1294,12 +1294,12 @@ public class CDOViewImpl extends Lifecycle implements InternalCDOView * @param timeStamp * The time stamp of the server transaction if this event was sent as a result of a successfully committed * transaction or <code>LOCAL_ROLLBACK</code> if this event was sent due to a local rollback. - * @param dirtyOIDs + * @param dirtyOIDandVersions * A set of the object IDs to be invalidated. <b>Implementation note:</b> This implementation expects the * dirtyOIDs set to be unmodifiable. It does not wrap the set (again). * @since 2.0 */ - public Set<CDOObject> handleInvalidation(long timeStamp, Set<CDOIDAndVersion> dirtyOIDs, + public Set<CDOObject> handleInvalidation(long timeStamp, Set<CDOIDAndVersion> dirtyOIDandVersions, Collection<CDOID> detachedOIDs) { Set<CDOObject> conflicts = null; @@ -1309,7 +1309,8 @@ public class CDOViewImpl extends Lifecycle implements InternalCDOView try { - conflicts = handleInvalidationWithoutNotification(dirtyOIDs, detachedOIDs, dirtyObjects, detachedObjects); + conflicts = handleInvalidationWithoutNotification(dirtyOIDandVersions, detachedOIDs, dirtyObjects, + detachedObjects); } finally { |