### Eclipse Workspace Patch 1.0 #P org.eclipse.emf.cdo.tests Index: src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java =================================================================== RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf.cdo/tests/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java,v retrieving revision 1.14 diff -u -r1.14 AbstractCDOTest.java --- src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java 19 Jan 2008 18:07:17 -0000 1.14 +++ src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java 20 Jan 2008 04:00:42 -0000 @@ -59,9 +59,13 @@ protected Repository createRepository() { Map props = new HashMap(); - // props.put(IRepository.PROP_SUPPORTING_REVISION_DELTAS, "true"); - // props.put(IRepository.PROP_CURRENT_LRU_CAPACITY, "20"); - // props.put(IRepository.PROP_REVISED_LRU_CAPACITY, "20"); + + // Uncomments the next two line to test RevisionDeltas with MEMStore + //props.put(IRepository.PROP_SUPPORTING_REVISION_DELTAS, "true"); + //props.put(IRepository.PROP_VERIFYING_REVISIONS, "true"); + + //props.put(IRepository.PROP_CURRENT_LRU_CAPACITY, "10"); + //props.put(IRepository.PROP_REVISED_LRU_CAPACITY, "10"); IStore store = createStore(); Index: src/org/eclipse/emf/cdo/tests/RollbackTest.java =================================================================== RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf.cdo/tests/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RollbackTest.java,v retrieving revision 1.2 diff -u -r1.2 RollbackTest.java --- src/org/eclipse/emf/cdo/tests/RollbackTest.java 28 Dec 2007 12:56:53 -0000 1.2 +++ src/org/eclipse/emf/cdo/tests/RollbackTest.java 20 Jan 2008 04:00:42 -0000 @@ -56,9 +56,11 @@ { // Client1 CDOResource resource1 = transaction1.createResource("/test1"); + Company company1 = Model1Factory.eINSTANCE.createCompany(); - resource1.getContents().add(company1); Category category1 = Model1Factory.eINSTANCE.createCategory(); + + resource1.getContents().add(company1); company1.getCategories().add(category1); transaction1.commit(); @@ -66,6 +68,8 @@ CDOResource resource2 = transaction2.getResource("/test1"); Company company2 = (Company)resource2.getContents().get(0); Category category2 = company2.getCategories().get(0); + + company2.setName("company2"); category2.setName("client2"); // Client1 @@ -90,16 +94,49 @@ assertEquals(false, transaction2.isDirty()); assertEquals(false, transaction2.hasConflict()); assertEquals("client1", category2.getName()); + assertEquals(null, company2.getName()); + { + CDOTransaction transaction3 = createNewTransaction(); + CDOResource resource3 = transaction3.getResource("/test1"); + Company company3 = (Company)resource3.getContents().get(0); + Category category3 = company3.getCategories().get(0); + assertEquals(null, company3.getName()); + assertEquals("client1", category3.getName()); + transaction3.close(); + transaction3.getSession().close(); + } + category2.setName("client2"); + company2.setName("company2"); + transaction2.commit(); assertEquals(false, transaction2.isDirty()); assertEquals(false, transaction2.hasConflict()); + assertEquals("company2", company2.getName()); assertEquals("client2", category2.getName()); sleep(500); + + { + CDOTransaction transaction3 = createNewTransaction(); + CDOResource resource3 = transaction3.getResource("/test1"); + Company company3 = (Company)resource3.getContents().get(0); + Category category3 = company3.getCategories().get(0); + assertEquals("company2", company3.getName()); + assertEquals("client2", category3.getName()); + transaction3.close(); + transaction3.getSession().close(); + } // Client1 assertEquals(false, transaction1.isDirty()); assertEquals(false, transaction1.hasConflict()); assertEquals("client2", category1.getName()); + assertEquals("company2", company1.getName()); + } + private CDOTransaction createNewTransaction() + { + CDOSession session = CDOUtil.openSession(getConnector(), REPOSITORY_NAME); + session.getPackageRegistry().putEPackage(Model1Package.eINSTANCE); + return session.openTransaction(); } } #P org.eclipse.emf.cdo.server Index: src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java =================================================================== RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf.cdo/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java,v retrieving revision 1.8 diff -u -r1.8 MEMStoreAccessor.java --- src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java 20 Jan 2008 01:58:48 -0000 1.8 +++ src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java 20 Jan 2008 04:00:42 -0000 @@ -55,7 +55,7 @@ { return (MEMStore)super.getStore(); } - + public IStoreChunkReader createChunkReader(CDORevision revision, CDOFeature feature) { return new MEMStoreChunkReader(this, revision, feature); @@ -84,6 +84,7 @@ public CDORevision readRevision(CDOID id, int referenceChunk) { InternalCDORevision storeRevision = (InternalCDORevision)getStore().getRevision(id); + InternalCDORevision newRevision = (InternalCDORevision)CDORevisionUtil.copy(storeRevision); // IRevisionManager revisionManager = getStore().getRepository().getRevisionManager(); // InternalCDORevision newRevision = new InternalCDORevision(revisionManager, storeRevision.getCDOClass(), // storeRevision @@ -104,8 +105,7 @@ // } // } // - // return newRevision; - return storeRevision; + return newRevision; } public CDORevision readRevisionByTime(CDOID id, int referenceChunk, long timeStamp) @@ -115,7 +115,12 @@ public CDORevision readRevisionByVersion(CDOID id, int referenceChunk, int version) { - throw new UnsupportedOperationException(); + CDORevision rev = getStore().getRevisionByVersion(id, version); + if (rev == null) + { + throw new IllegalStateException("Cannot find id " + id + " with version " + version); + } + return CDORevisionUtil.copy(rev); } public CDOID readResourceID(String path) @@ -134,7 +139,9 @@ public void writeRevision(InternalCDORevision revision) { - newRevisions.add(revision); + CDORevision newRevision = CDORevisionUtil.copy(revision); + getStore().addRevision(newRevision); + newRevisions.add( newRevision ); } @Override @@ -143,8 +150,20 @@ InternalCDORevision revision = (InternalCDORevision)getStore().getRevision(delta.getID()); InternalCDORevision newRevision = (InternalCDORevision)CDORevisionUtil.copy(revision); delta.apply(newRevision); + getStore().addRevision(newRevision); newRevisions.add(newRevision); } + + @Override + public InternalCDORevision verifyRevision(CDORevision revision) + { + InternalCDORevision storeRevision = (InternalCDORevision)getStore().getRevision(revision.getID()); + if (storeRevision.getVersion() != revision.getVersion()) + { + revision = (InternalCDORevision)CDORevisionUtil.copy(storeRevision); + } + return (InternalCDORevision)revision; + } @Override public void release() @@ -154,14 +173,14 @@ public void commit() { - MEMStore store = getStore(); - for (CDORevision revision : newRevisions) - { - store.addRevision(revision); - } } public void rollback() { + MEMStore store = getStore(); + for (CDORevision revision : newRevisions) + { + store.removeRevision(revision); + } } }